• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps AEADBadTagException Caused by KeyStoreException: Signature/MAC verification failed

I use AES key with this code to encrypt:

private EncryptionResult encrypt(SecretKey secretKey, String message) throws Throwable {
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
byte[] cipherText = cipher.doFinal(message.getBytes(StandardCharsets.UTF_8));

// save in an object encoded with iv
EncryptionResult result = new EncryptionResult(Base64.encodeToString(cipherText, Base64.NO_WRAP), cipher.getIV());
return result;
}


And I use this code to decrypt:

private String decrypt(SecretKey secretKey, EncryptionResult encryptionResult) throws Throwable {
byte[] salt = encryptionResult.getIV();
GCMParameterSpec gCMParameterSpec = new GCMParameterSpec(128, salt);

Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
cipher.init(Cipher.DECRYPT_MODE, secretKey, gCMParameterSpec);
byte[] decodeBase64 = Base64.decode(encryptionResult.getBase64EncryptedValue(), Base64.NO_WRAP);
byte[] decryptedValue = cipher.doFinal(decodeBase64);
return new String(decryptedValue);
}


The "message" that is being encrypted is a RSA key size 2048.
It works on MOST of the popular devices, but the decryption fails on some others like Meizu (M5, M3E), Huawei (P40, Nova 5T), Samsungs (J7, A10), etc... where it crashes do to "AEADBadTagException... Caused by KeyStoreException: Signature/MAC verification failed".
If I reduce the "message" to 1024, it also works fine (although as far as I know, AES key has no size limitation for encryption).
I also tried using CipherOutputStream/CipherInputStream, but got the same result.
All looks good with Base64 encoding/decoding, tags, iv, keyStore... any other components envolved in the process.

Does anyone can shed some light why some devices do the work, while others fail?

Post the latest Note 20 rumors here

Hi Greegom, welcome to the cool kids' club... it's great to have you here!

I've heard rumors of the new Fold (whatever they call it) having an S Pen. The screen is reported to be ultra-thin glass: regardless, the S Pen would reside beneath it anyway. That gorgeous, huge screen is begging for an S Pen - artists, business people, lots of folks would love that. Including me! I use that S Pen almost every hour of the day: the bluetooth control of the camera, music, etc. is so useful. Plus, the precision of the S Pen lets me work more efficiently with fewer mistakes.

Let's hope the new Fold has an S Pen and its features built in. If so, one must wonder if that's the next evolution of the Galaxy Note, 10 years later...

Help Unknown stream audio comming from phone, need hidden Process & app monitoring, & general security.

Thanks, those developer controlls look like just what i need. Now to wait and see if it pops back up again. That's the tricky one because it's not actually my phone.

I can say though it is definetly not an add form some app running. It's as i described in the post. It was weird because it sounded like we where the hackers listening in on someone who was unaware.
But i guessed it more sounded like somebody facebook livestreaming a party.

This news source that I use used to have an annoying feature.

I would click on a link, and as it was loading, a window would pop up with a video that would take forever to load.
So I would start to read the article, and once the video loaded everything scrolled back to the top to that pest of a window- where the story I was just reading is replayed word for word, slowly, with pictures, and an annoying soundtrack.

Needless to say, this was extremely aggrevating, as I was oten already half way through the article when this would happen.

Anyway, this stupid, annoying soundtrack was so low to almost go unnoticed.

And sometimes, it would just start playing out of nowhere, even if I was not on that news site. It must have been getting stored inside the cache of the browser. And since I use that browser all the time, it is almost always active.

After a few profane e-mails, they finally decided to ditch the whole video window, thank God.

Haven't had the issue since.

Filter

Back
Top Bottom