Hi,
I received from python the Ciphertext (this is formated from StringEcrypted + first 4 elements from MAC.
When I'll try to decrypt the message I received wrong MAC.
I think the problem is on MAC. I'm able to set the MAC length with 4 on the SecretBox?
I'll add the code:
Future<List> decrypt(List message) async {
final algorithm = AesGcm.with128bits();
final key = await kdf(isEncrypt: true);
final secretKey = SecretKey(key);
final mac = Mac(message.skip(message.length - 4).toList());
final secretMessage =
SecretBox(message.take(message.length - 4).toList(), nonce: HEX.decode(cpIV), mac: mac);
final clearText = await algorithm.decrypt(secretMessage, secretKey: secretKey);
print(clearText);
return clearText;
}
SecretBox details
"Nonce: [174, 1, 226, 226, 211, 55, 4, 206, 188, 172, 17, 149]"
"Ciphertext: [179, 43, 17]"
"MAC: [255, 47, 7, 170]"
Hi,
I received from python the Ciphertext (this is formated from StringEcrypted + first 4 elements from MAC.
When I'll try to decrypt the message I received wrong MAC.
I think the problem is on MAC. I'm able to set the MAC length with 4 on the SecretBox?
I'll add the code:
Future<List> decrypt(List message) async {
final algorithm = AesGcm.with128bits();
final key = await kdf(isEncrypt: true);
final secretKey = SecretKey(key);
final mac = Mac(message.skip(message.length - 4).toList());
final secretMessage =
SecretBox(message.take(message.length - 4).toList(), nonce: HEX.decode(cpIV), mac: mac);
final clearText = await algorithm.decrypt(secretMessage, secretKey: secretKey);
print(clearText);
return clearText;
}
SecretBox details
"Nonce: [174, 1, 226, 226, 211, 55, 4, 206, 188, 172, 17, 149]"
"Ciphertext: [179, 43, 17]"
"MAC: [255, 47, 7, 170]"