File tree Expand file tree Collapse file tree
waltid-libraries/crypto/waltid-crypto/src
androidDeviceTest/kotlin/id/walt/crypto
androidMain/kotlin/id/walt/crypto
iosMain/kotlin/id/walt/crypto Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,6 +45,17 @@ class AndroidKeyTest {
4545 assertFailsWith<IllegalStateException >(" public platform key should not sign for $type " ) {
4646 publicKey.signRaw(" nope" .encodeToByteArray())
4747 }
48+
49+ val publicKeyRepresentation = publicKey.getPublicKeyRepresentation()
50+ when (type) {
51+ KeyType .secp256r1 -> assertEquals(65 , publicKeyRepresentation.size)
52+ KeyType .secp384r1 -> assertEquals(97 , publicKeyRepresentation.size)
53+ KeyType .secp521r1 -> assertEquals(133 , publicKeyRepresentation.size)
54+ else -> Unit
55+ }
56+ if (type != KeyType .RSA ) {
57+ assertEquals(0x04 , publicKeyRepresentation.first().toInt())
58+ }
4859 }
4960 }
5061
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ sealed class AndroidKey : Key() {
100100 }
101101
102102 override suspend fun getPublicKey (): Key = Platform (options, hasPrivateKey = false )
103- override suspend fun getPublicKeyRepresentation (): ByteArray = signer().publicKey.encodeToTlv().derEncoded
103+ override suspend fun getPublicKeyRepresentation (): ByteArray = signer().publicKey.iosEncoded
104104 override suspend fun getMeta (): KeyMeta = JwkKeyMeta (getKeyId())
105105 override suspend fun deleteKey (): Boolean = runCatching {
106106 AndroidKeyStoreProvider .deleteSigningKey(options.kid).getOrThrow()
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ sealed class IosKey : Key() {
110110 }
111111
112112 override suspend fun getPublicKey (): Key = Platform (options, hasPrivateKey = false )
113- override suspend fun getPublicKeyRepresentation (): ByteArray = signer().publicKey.encodeToTlv().derEncoded
113+ override suspend fun getPublicKeyRepresentation (): ByteArray = signer().publicKey.iosEncoded
114114 override suspend fun getMeta (): KeyMeta = JwkKeyMeta (getKeyId())
115115 override suspend fun deleteKey (): Boolean = runCatching {
116116 IosKeychainProvider .deleteSigningKey(options.kid).getOrThrow()
You can’t perform that action at this time.
0 commit comments