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

UNSUPPORTED_ALGORITHM Error #139

Open
haizadvnet opened this issue Apr 2, 2023 · 2 comments
Open

UNSUPPORTED_ALGORITHM Error #139

haizadvnet opened this issue Apr 2, 2023 · 2 comments

Comments

@haizadvnet
Copy link

haizadvnet commented Apr 2, 2023

I got PlatformException (PlatformException(UNSUPPORTED_ALGORITHM, cryptography_flutter does not support algorithm null in Android., null, null))

Source code

final pbkdf2 = FlutterPbkdf2(
        macAlgorithm: Hmac.sha1(),
        iterations: 1001,
        bits: 256,
      );

final newSecretKey = await pbkdf2.deriveKeyFromPassword(password: pass, nonce: salt.codeUnits); // <-- throws error when running the deriveKeyFromPassword function.
_internal.dart

await _methodChannel.invokeMethod('encrypt', {}); <-- the error comes from this invokeMethod

It throws error only if I checked All Exception on vsCode breakpoints.

image

@haizadvnet
Copy link
Author

I am using AES CBC.

I already edited the CryptographyFlutterPlugin.kt file

private fun androidCipherAlgo(dartAlgo: String?): String? {
        return when (dartAlgo) {
            "AES_GCM" -> "AES/GCM/NoPadding"
            "AES_CBC" -> "AES/CBC/NoPadding"
            "CHACHA20_POLY1305_AEAD" -> "ChaCha20/Poly1305/NoPadding"
            else -> null
        }
    }

    private fun cipherMacLength(dartMacAlgo: String?): Int? {
        return when (dartMacAlgo) {
            "AES_GCM" -> 16
            "AES_CBC" -> 32
            "CHACHA20_POLY1305_AEAD" -> 16
            else -> null
        }
    }

and still got the same error :/

@jakenoble
Copy link

Did you get this working? I have the same error on Hmac.sha512() and Hmac.sha256()

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

2 participants