Browse Source

Small amount of crypto cleanup.

Adam Ierymenko 12 years ago
parent
commit
02f3369185
2 changed files with 9 additions and 2 deletions
  1. 3 2
      node/C25519.cpp
  2. 6 0
      node/SHA512.cpp

+ 3 - 2
node/C25519.cpp

@@ -29,8 +29,9 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 
 
-#include "Utils.hpp"
+#include "Constants.hpp"
 #include "C25519.hpp"
 #include "C25519.hpp"
+#include "Utils.hpp"
 #include "SHA512.hpp"
 #include "SHA512.hpp"
 
 
 namespace ZeroTier {
 namespace ZeroTier {
@@ -1024,7 +1025,7 @@ typedef struct
 
 
 
 
 /* Packed coordinates of the base point */
 /* Packed coordinates of the base point */
-const ge25519 ge25519_base = {{{0x1A, 0xD5, 0x25, 0x8F, 0x60, 0x2D, 0x56, 0xC9, 0xB2, 0xA7, 0x25, 0x95, 0x60, 0xC7, 0x2C, 0x69, 
+static const ge25519 ge25519_base = {{{0x1A, 0xD5, 0x25, 0x8F, 0x60, 0x2D, 0x56, 0xC9, 0xB2, 0xA7, 0x25, 0x95, 0x60, 0xC7, 0x2C, 0x69, 
                                 0x5C, 0xDC, 0xD6, 0xFD, 0x31, 0xE2, 0xA4, 0xC0, 0xFE, 0x53, 0x6E, 0xCD, 0xD3, 0x36, 0x69, 0x21}},
                                 0x5C, 0xDC, 0xD6, 0xFD, 0x31, 0xE2, 0xA4, 0xC0, 0xFE, 0x53, 0x6E, 0xCD, 0xD3, 0x36, 0x69, 0x21}},
                               {{0x58, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 
                               {{0x58, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 
                                 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66}},
                                 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66}},

+ 6 - 0
node/SHA512.cpp

@@ -30,6 +30,7 @@
 #include <string.h>
 #include <string.h>
 
 
 #include "SHA512.hpp"
 #include "SHA512.hpp"
+#include "Utils.hpp"
 
 
 namespace ZeroTier {
 namespace ZeroTier {
 
 
@@ -47,6 +48,10 @@ Public domain.
 
 
 #define uint64 uint64_t
 #define uint64 uint64_t
 
 
+#define load_bigendian(x) Utils::ntoh(*((const uint64_t *)(x)))
+#define store_bigendian(x,u) (*((uint64_t *)(x)) = Utils::hton((u)))
+
+#if 0
 static uint64 load_bigendian(const unsigned char *x)
 static uint64 load_bigendian(const unsigned char *x)
 {
 {
   return
   return
@@ -72,6 +77,7 @@ static void store_bigendian(unsigned char *x,uint64 u)
   x[1] = u; u >>= 8;
   x[1] = u; u >>= 8;
   x[0] = u;
   x[0] = u;
 }
 }
+#endif
 
 
 #define SHR(x,c) ((x) >> (c))
 #define SHR(x,c) ((x) >> (c))
 #define ROTR(x,c) (((x) >> (c)) | ((x) << (64 - (c))))
 #define ROTR(x,c) (((x) >> (c)) | ((x) << (64 - (c))))