Adam Ierymenko 6 years ago
parent
commit
b14a59629c
3 changed files with 11 additions and 5 deletions
  1. 1 1
      Makefile
  2. 0 1
      osdep/MacEthernetTapAgent.c
  3. 10 3
      selftest.cpp

+ 1 - 1
Makefile

@@ -6,7 +6,7 @@ CMAKE_OPTS := -DCMAKE_BUILD_TYPE=Release
 .PHONY: all
 .PHONY: all
 
 
 all:
 all:
-	mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. ${CMAKE_OPTS} && $(MAKE)
+	mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. ${CMAKE_OPTS} && $(MAKE) -j$(shell getconf _NPROCESSORS_ONLN)
 
 
 clean:
 clean:
 	rm -rf ${BUILDDIR}
 	rm -rf ${BUILDDIR}

+ 0 - 1
osdep/MacEthernetTapAgent.c

@@ -196,7 +196,6 @@ static void die()
 
 
 int main(int argc,char **argv)
 int main(int argc,char **argv)
 {
 {
-	char buf[128];
 	struct ifreq ifr;
 	struct ifreq ifr;
 	u_int fl;
 	u_int fl;
 	fd_set rfds,wfds,efds;
 	fd_set rfds,wfds,efds;

+ 10 - 3
selftest.cpp

@@ -214,7 +214,7 @@ static int testCrypto()
 	}
 	}
 	double gcmBytes = 0.0;
 	double gcmBytes = 0.0;
 	int64_t start = OSUtils::now();
 	int64_t start = OSUtils::now();
-	for(unsigned long i=0;i<100000;++i) {
+	for(unsigned long i=0;i<50000;++i) {
 		tv.gcmEncrypt((const uint8_t *)hexbuf,buf1,sizeof(buf1),nullptr,0,buf2,(uint8_t *)(hexbuf + 32),16);
 		tv.gcmEncrypt((const uint8_t *)hexbuf,buf1,sizeof(buf1),nullptr,0,buf2,(uint8_t *)(hexbuf + 32),16);
 		tv.gcmEncrypt((const uint8_t *)hexbuf,buf2,sizeof(buf2),nullptr,0,buf1,(uint8_t *)(hexbuf + 32),16);
 		tv.gcmEncrypt((const uint8_t *)hexbuf,buf2,sizeof(buf2),nullptr,0,buf1,(uint8_t *)(hexbuf + 32),16);
 		gcmBytes += (double)(sizeof(buf1) * 2);
 		gcmBytes += (double)(sizeof(buf1) * 2);
@@ -224,7 +224,7 @@ static int testCrypto()
 	std::cout << ((gcmBytes / 1048576.0) / ((double)(end - start) / 1000.0)) << " MiB/second" << std::endl << "  AES-256 ECB scramble (benchmark): "; std::cout.flush();
 	std::cout << ((gcmBytes / 1048576.0) / ((double)(end - start) / 1000.0)) << " MiB/second" << std::endl << "  AES-256 ECB scramble (benchmark): "; std::cout.flush();
 	double ecbBytes = 0.0;
 	double ecbBytes = 0.0;
 	start = OSUtils::now();
 	start = OSUtils::now();
-	for(unsigned long i=0;i<100000;++i) {
+	for(unsigned long i=0;i<50000;++i) {
 		tv.ecbScramble(buf1,sizeof(buf1),buf2);
 		tv.ecbScramble(buf1,sizeof(buf1),buf2);
 		tv.ecbScramble(buf2,sizeof(buf1),buf1);
 		tv.ecbScramble(buf2,sizeof(buf1),buf1);
 		ecbBytes += (double)(sizeof(buf1) * 2);
 		ecbBytes += (double)(sizeof(buf1) * 2);
@@ -234,7 +234,7 @@ static int testCrypto()
 	std::cout << ((ecbBytes / 1048576.0) / ((double)(end - start) / 1000.0)) << " MiB/second" << std::endl << "  AES-256 GCM + ECB scramble (benchmark): "; std::cout.flush();
 	std::cout << ((ecbBytes / 1048576.0) / ((double)(end - start) / 1000.0)) << " MiB/second" << std::endl << "  AES-256 GCM + ECB scramble (benchmark): "; std::cout.flush();
 	ecbBytes = 0.0;
 	ecbBytes = 0.0;
 	start = OSUtils::now();
 	start = OSUtils::now();
-	for(unsigned long i=0;i<100000;++i) {
+	for(unsigned long i=0;i<50000;++i) {
 		tv.gcmEncrypt((const uint8_t *)hexbuf,buf1,sizeof(buf1),nullptr,0,buf2,(uint8_t *)(hexbuf + 32),16);
 		tv.gcmEncrypt((const uint8_t *)hexbuf,buf1,sizeof(buf1),nullptr,0,buf2,(uint8_t *)(hexbuf + 32),16);
 		tv.ecbScramble(buf1,sizeof(buf1),buf2);
 		tv.ecbScramble(buf1,sizeof(buf1),buf2);
 		tv.gcmEncrypt((const uint8_t *)hexbuf,buf2,sizeof(buf2),nullptr,0,buf1,(uint8_t *)(hexbuf + 32),16);
 		tv.gcmEncrypt((const uint8_t *)hexbuf,buf2,sizeof(buf2),nullptr,0,buf1,(uint8_t *)(hexbuf + 32),16);
@@ -328,6 +328,13 @@ static int testCrypto()
 		return -1;
 		return -1;
 	}
 	}
 	std::cout << "PASS" << std::endl;
 	std::cout << "PASS" << std::endl;
+	std::cout << "[crypto] Benchmarking SHA-512 (64 byte input)... "; std::cout.flush();
+	start = OSUtils::now();
+	for(unsigned int i=0;i<2000000;++i) {
+		SHA512(buf1,buf1,64);
+	}
+	end = OSUtils::now();
+	std::cout << (uint64_t)(2000000.0 / ((double)(end - start) / 1000.0)) << " hashes/second" << std::endl;
 	std::cout << "[crypto] Testing SHA-384... "; std::cout.flush();
 	std::cout << "[crypto] Testing SHA-384... "; std::cout.flush();
 	SHA384(buf1,sha512TV0Input,(unsigned int)strlen(sha512TV0Input));
 	SHA384(buf1,sha512TV0Input,(unsigned int)strlen(sha512TV0Input));
 	if (memcmp(buf1,sha384TV0Digest,48)) {
 	if (memcmp(buf1,sha384TV0Digest,48)) {