2
0
Эх сурвалжийг харах

More selective push of AES modifications and refactoring stuff.

Adam Ierymenko 4 жил өмнө
parent
commit
1ad555a071
2 өөрчлөгдсөн 10 нэмэгдсэн , 5 устгасан
  1. 5 0
      node/SHA512.cpp
  2. 5 5
      selftest.cpp

+ 5 - 0
node/SHA512.cpp

@@ -272,3 +272,8 @@ void KBKDFHMACSHA384(const uint8_t key[ZT_SYMMETRIC_KEY_SIZE],const char label,c
 }
 
 } // namespace ZeroTier
+
+// Internally re-export to included C code, which includes some fast crypto code ported in on some platforms.
+// This eliminates the need to link against a third party SHA512() from this code
+extern "C" void ZT_sha512internal(void *digest,const void *data,unsigned int len)
+{ ZeroTier::SHA512(digest,data,len); }

+ 5 - 5
selftest.cpp

@@ -198,7 +198,7 @@ static int testCrypto()
 			bytes += 1234567.0;
 		}
 		uint64_t end = OSUtils::now();
-		SHA512::hash(buf1,bb,1234567);
+		SHA512(buf1,bb,1234567);
 		std::cout << ((bytes / 1048576.0) / ((long double)(end - start) / 1024.0)) << " MiB/second (" << Utils::hex(buf1,16,hexbuf) << ')' << std::endl;
 		::free((void *)bb);
 	}
@@ -250,13 +250,13 @@ static int testCrypto()
 			bytes += 1234567.0;
 		}
 		uint64_t end = OSUtils::now();
-		SHA512::hash(buf1,bb,1234567);
+		SHA512(buf1,bb,1234567);
 		std::cout << ((bytes / 1048576.0) / ((long double)(end - start) / 1024.0)) << " MiB/second (" << Utils::hex(buf1,16,hexbuf) << ')' << std::endl;
 		::free((void *)bb);
 	}
 
 	std::cout << "[crypto] Testing SHA-512... "; std::cout.flush();
-	SHA512::hash(buf1,sha512TV0Input,(unsigned int)strlen(sha512TV0Input));
+	SHA512(buf1,sha512TV0Input,(unsigned int)strlen(sha512TV0Input));
 	if (memcmp(buf1,sha512TV0Digest,64)) {
 		std::cout << "FAIL" << std::endl;
 		return -1;
@@ -617,8 +617,8 @@ static int testPacket()
 		return -1;
 	}
 
-	a.armor(salsaKey,true);
-	if (!a.dearmor(salsaKey)) {
+	a.armor(salsaKey,true,nullptr);
+	if (!a.dearmor(salsaKey,nullptr)) {
 		std::cout << "FAIL (encrypt-decrypt/verify)" << std::endl;
 		return -1;
 	}