Skip to content

Decryption not working on real device, but on emulator it works fine #53

@CosminCirlea

Description

@CosminCirlea

Hello!
I'm trying to decrypt data and it's working on any emulator, but real devices do not work (tested on API 24 and 30).
Any clues? Below is my code snippet

` public String decryptData(String transportKey, String cipher){
lazySodium = new LazySodiumAndroid(new SodiumAndroid());
byte[] cipherBytes = Base64.decode(cipher, Base64.DEFAULT);
byte[] transportKeyBytes = Base64.decode(transportKey, Base64.DEFAULT);
byte[] nonceBytes = Arrays.copyOfRange(cipherBytes, 0, AEAD.AES256GCM_NPUBBYTES);
byte[] cipherTextBytes = Arrays.copyOfRange(cipherBytes, AEAD.AES256GCM_NPUBBYTES, cipherBytes.length);

    long[] outMessageLength = new long[1];
    byte[] outMessage = new byte[1000];

    lazySodium.cryptoAeadAES256GCMDecrypt(outMessage, outMessageLength, null, cipherTextBytes, cipherTextBytes.length, null, 0, nonceBytes, transportKeyBytes);
    outMessage = Arrays.copyOfRange(outMessage, 0, (int)outMessageLength[0]);
    return new String(outMessage, StandardCharsets.UTF_8);
}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions