diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-10-18 17:39:48 -0400 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-10-18 17:39:48 -0400 |
| commit | 8c9b73f67b786d9c08ffc98cc4b0f9b7c44b7717 (patch) | |
| tree | d75961901641f1d35ed51e604e3fe0fa7e8cb6a2 /node/NodeConfig.cpp | |
| parent | 37e3bc3467d0f0648abe9dfb51f558465211fa87 (diff) | |
| download | infinitytier-8c9b73f67b786d9c08ffc98cc4b0f9b7c44b7717.tar.gz infinitytier-8c9b73f67b786d9c08ffc98cc4b0f9b7c44b7717.zip | |
Make Salsa20 variable-round, allowing for Salsa20/12 to be used for Packet encrypt and decrypt. Profiling analysis found that Salsa20 encrypt was accounting for a nontrivial percentage of CPU time, so it makes sense to cut this load fundamentally. There are no published attacks against Salsa20/12, and DJB believes 20 rounds to be overkill. This should be more than enough for our needs. Obviously incorporating ASM Salsa20 is among the next steps for performance.
Diffstat (limited to 'node/NodeConfig.cpp')
| -rw-r--r-- | node/NodeConfig.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/node/NodeConfig.cpp b/node/NodeConfig.cpp index 0dda8da7..f26cd8ea 100644 --- a/node/NodeConfig.cpp +++ b/node/NodeConfig.cpp @@ -49,6 +49,7 @@ #include "Logger.hpp" #include "Topology.hpp" #include "Demarc.hpp" +#include "Packet.hpp" #include "InetAddress.hpp" #include "Peer.hpp" #include "Salsa20.hpp" @@ -283,7 +284,7 @@ std::vector< Buffer<ZT_NODECONFIG_MAX_PACKET_SIZE> > NodeConfig::encodeControlMe Utils::getSecureRandom(iv,8); memcpy(packet.field(8,8),iv,8); - Salsa20 s20(key,256,iv); + Salsa20 s20(key,256,iv,ZT_PROTO_SALSA20_ROUNDS); s20.encrypt(packet.field(16,packet.size() - 16),packet.field(16,packet.size() - 16),packet.size() - 16); memcpy(keytmp,key,32); @@ -322,7 +323,7 @@ bool NodeConfig::decodeControlMessagePacket(const void *key,const void *data,uns if (!Utils::secureEq(packet.field(0,8),poly1305tag,8)) return false; - Salsa20 s20(key,256,packet.field(8,8)); + Salsa20 s20(key,256,packet.field(8,8),ZT_PROTO_SALSA20_ROUNDS); s20.decrypt(packet.field(16,packet.size() - 16),packet.field(16,packet.size() - 16),packet.size() - 16); conversationId = packet.at<uint32_t>(16); |
