Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hmac for wasm verifySignature throws exception #62

Open
123abceng opened this issue Feb 15, 2025 · 1 comment
Open

hmac for wasm verifySignature throws exception #62

123abceng opened this issue Feb 15, 2025 · 1 comment

Comments

@123abceng
Copy link

123abceng commented Feb 15, 2025

        val keyString = "0c60ae04fbb17fe36f4e84631a5b8f3cd6d0cd46e80056bdfec97fd305f764daadef8ae1adc89b203043d7e2af1fb341df0ce5f66dfe3204ec3a9831532a8e4c"
        val key = Cryptography.Instance.hmac.keyDecoder(SHA512).decodeFromByteString(HMAC.Key.Format.RAW, keyString.hexToByteString())
        val signature = "5159e5bcdb6396a4453998ab477028f2103876bd4086855b7b04eb0ca57c3ac262c3fe38414971e53aef5ac094731b629de94afc2f6381d3dc6bec70f58cba73"
        var resultString = "no exception"
        var result = false
        try {
            result = key
                .signatureVerifier()
//                .verifySignature(byteArrayOf(1,2,3), signature.hexToByteArray()) // << this line
                .tryVerifySignature(byteArrayOf(1,2,3), signature.hexToByteArray())
        } catch (e: Exception) {
            resultString = e.message.toString() + "\n" + e::class.qualifiedName
        }

it feels verifySignature calls non-suspend method, thus webcrypto complains. tryVerifySignature is working
The same behavior observed for esdsa.

@123abceng
Copy link
Author

AES.kt:

    @SubclassOptInRequired(CryptographyProviderApi::class)
    public interface IvDecryptor : Decryptor {
        @DelicateCryptographyApi
        public suspend fun decryptWithIv(iv: ByteArray, ciphertext: ByteArray): ByteArray {
            return decryptWithIvBlocking(iv, ciphertext)
        }


here we also have limitations for wasm (AES-CBC)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant