|
|
@ -97,11 +97,18 @@ namespace garlic |
|
|
|
|
|
|
|
|
|
|
|
void ECIESX25519AEADRatchetSession::ResetKeys () |
|
|
|
void ECIESX25519AEADRatchetSession::ResetKeys () |
|
|
|
{ |
|
|
|
{ |
|
|
|
// TODO : use precalculated hashes
|
|
|
|
static const uint8_t protocolNameHash[32] = |
|
|
|
static const char protocolName[41] = "Noise_IKelg2+hs2_25519_ChaChaPoly_SHA256"; // 40 bytes
|
|
|
|
{ |
|
|
|
SHA256 ((const uint8_t *)protocolName, 40, m_H); |
|
|
|
0x4c, 0xaf, 0x11, 0xef, 0x2c, 0x8e, 0x36, 0x56, 0x4c, 0x53, 0xe8, 0x88, 0x85, 0x06, 0x4d, 0xba, |
|
|
|
memcpy (m_CK, m_H, 32); |
|
|
|
0xac, 0xbe, 0x00, 0x54, 0xad, 0x17, 0x8f, 0x80, 0x79, 0xa6, 0x46, 0x82, 0x7e, 0x6e, 0xe4, 0x0c |
|
|
|
SHA256 (m_H, 32, m_H); |
|
|
|
}; // SHA256("Noise_IKelg2+hs2_25519_ChaChaPoly_SHA256"), 40 bytes
|
|
|
|
|
|
|
|
static const uint8_t hh[32] = |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
0x9c, 0xcf, 0x85, 0x2c, 0xc9, 0x3b, 0xb9, 0x50, 0x44, 0x41, 0xe9, 0x50, 0xe0, 0x1d, 0x52, 0x32, |
|
|
|
|
|
|
|
0x2e, 0x0d, 0x47, 0xad, 0xd1, 0xe9, 0xa5, 0x55, 0xf7, 0x55, 0xb5, 0x69, 0xae, 0x18, 0x3b, 0x5c |
|
|
|
|
|
|
|
}; // SHA256 (protocolNameHash)
|
|
|
|
|
|
|
|
memcpy (m_CK, protocolNameHash, 32); |
|
|
|
|
|
|
|
memcpy (m_H, hh, 32); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ECIESX25519AEADRatchetSession::MixHash (const uint8_t * buf, size_t len) |
|
|
|
void ECIESX25519AEADRatchetSession::MixHash (const uint8_t * buf, size_t len) |
|
|
|