You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's define ASSOCIATED_DATA as data trasmitted as plaintext and included in MAC calculation. The content of ASSOCIATED_DATA (AD) depends on the scope of encryptor and whether data is associated with the request or the response1:
Validate the MAC value in payload against expected MAC value. Include ASSOCIATED_DATA and SHARED_INFO_2. If the MAC values are different, terminate the decryption.
byte[] AD;
if (TIMESTAMP != null) {
// Protocol 3.2+byte[] TIMESTAMP_BYTES = ByteUtils.encode(TIMESTAMP);
AD = ByteUtils.concat(ASSOCIATED_DATA, ByteUtils.join(NONCE, TIMESTAMP_BYTES, KEY_EPH_PUB));
} else {
// Protocol V3.1 and olderAD = newbyte[0];
}
byte[] DATA = Bytes.concat(AD, DATA_ENCRYPTED, SHARED_INFO_2);
byte[] MAC_EXPECTED = Mac.hmacSha256(KEY_MAC, DATA);
if (MAC_EXPECTED != MAC) {
throwEciesException("Invalid MAC"); // terminate the validation with an error
}
The text was updated successfully, but these errors were encountered:
Changes in ECIES algorithm
Associated data
Let's define
ASSOCIATED_DATA
as data trasmitted as plaintext and included in MAC calculation. The content ofASSOCIATED_DATA
(AD) depends on the scope of encryptor and whether data is associated with the request or the response1:Encryption
In ECIES Encryption, let's keep the existing algorithm up to step 6 and change the next steps:
ASSOCIATED_DATA
andSHARED_INFO_2
.As you can see the encryptor includes internally more data into MAC calculation than ASSOCIATED_DATA.
Decryption
In ECIES Decryption, change step 4:
ASSOCIATED_DATA
andSHARED_INFO_2
. If the MAC values are different, terminate the decryption.The text was updated successfully, but these errors were encountered: