diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-03-10 17:44:25 -0800 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-03-10 17:44:25 -0800 |
commit | aad6f79efa9a335f13274232519b65d90f3cd672 (patch) | |
tree | 1c90abd4f94f2cfc217b3d09ba2c4f87e91421c8 /node | |
parent | 0c00b8370207c51fbc9c9901cfa0daccc9707295 (diff) | |
download | infinitytier-aad6f79efa9a335f13274232519b65d90f3cd672.tar.gz infinitytier-aad6f79efa9a335f13274232519b65d90f3cd672.zip |
Also must mask off counter bits in IV in cryptField.
Diffstat (limited to 'node')
-rw-r--r-- | node/Packet.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/node/Packet.cpp b/node/Packet.cpp index 80ea2de7..aaceb9aa 100644 --- a/node/Packet.cpp +++ b/node/Packet.cpp @@ -2025,9 +2025,11 @@ bool Packet::dearmor(const void *key) void Packet::cryptField(const void *key,unsigned int start,unsigned int len) { - unsigned char discard[32]; - Salsa20 s20(key,256,field(ZT_PACKET_IDX_IV,8)); - s20.crypt12(ZERO_KEY,discard,sizeof(discard)); // discard the first 32 bytes of key stream (the ones use for MAC in armor()) as a precaution + const uint8_t *const data = reinterpret_cast<const uint8_t *>(data()); + uint8_t iv[8]; + for(int i=0;i<8;++i) iv[i] = data[i]; + iv[7] &= 0xf8; // mask off least significant 3 bits of packet ID / IV since this is unset when this function gets called + Salsa20 s20(key,256,data); unsigned char *const ptr = field(start,len); s20.crypt12(ptr,ptr,len); } |