initial-quantum
This commit is contained in:
1 parent
813d3aa06e
commit
ae1ce9673a
6924 files changed
+1908770
-17453
No files matched your search
+16
-3
@@ -1085,14 +1085,27 @@ bool Packet::dearmor(const void *key,const AES aesKeys[2])
|
||||
tag[1] = *reinterpret_cast<uint64_t *>(data + ZT_PACKET_IDX_MAC);
|
||||
#endif
|
||||
|
||||
// GMAC-SIV decrypts in place, so a failed attempt would leave
|
||||
// garbage in the payload and make any retry on another key hash
|
||||
// ciphertext that no longer exists. Callers rely on being able to
|
||||
// retry -- HELLO, OK(HELLO) and PQ_KEYS stay armed with the
|
||||
// classical key while the session key is hybrid -- so decrypt to
|
||||
// scratch, authenticate it, and only then commit.
|
||||
uint8_t scratch[ZT_PROTO_MAX_PACKET_LENGTH];
|
||||
memcpy(scratch, payload, payloadLen);
|
||||
|
||||
AES::GMACSIVDecryptor dec(aesKeys[0],aesKeys[1]);
|
||||
dec.init(tag, payload);
|
||||
dec.init(tag, scratch);
|
||||
const uint8_t oldFlags = data[ZT_PACKET_IDX_FLAGS];
|
||||
data[ZT_PACKET_IDX_FLAGS] &= 0xf8;
|
||||
dec.aad(data + ZT_PACKET_IDX_DEST,11);
|
||||
data[ZT_PACKET_IDX_FLAGS] = oldFlags;
|
||||
dec.update(payload, payloadLen);
|
||||
return dec.finish();
|
||||
dec.update(scratch, payloadLen);
|
||||
if (!dec.finish()) {
|
||||
return false;
|
||||
}
|
||||
memcpy(payload, scratch, payloadLen);
|
||||
return true;
|
||||
}
|
||||
} else if ((cs == ZT_PROTO_CIPHER_SUITE__C25519_POLY1305_NONE)||(cs == ZT_PROTO_CIPHER_SUITE__C25519_POLY1305_SALSA2012)) {
|
||||
uint8_t mangledKey[32];
|
||||
|
||||
Reference in new issue
Block a user