cryptotest.c (134911) | cryptotest.c (140407) |
---|---|
1/*- 2 * Copyright (c) 2004 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 25 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 28 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGES. 31 * | 1/*- 2 * Copyright (c) 2004 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 25 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 28 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGES. 31 * |
32 * $FreeBSD: head/tools/tools/crypto/cryptotest.c 134911 2004-09-07 18:35:00Z sam $ | 32 * $FreeBSD: head/tools/tools/crypto/cryptotest.c 140407 2005-01-18 07:42:17Z phk $ |
33 */ 34 35/* 36 * Simple tool for testing hardware/system crypto support. 37 * 38 * cryptotest [-czsbv] [-a algorithm] [count] [size ...] 39 * 40 * Run count iterations of a crypt+decrypt or mac operation on a buffer of --- 169 unchanged lines hidden (view full) --- 210 const char a[] = { 211 0x10,0x54,0x11,0x48,0x45,0x12,0x4f,0x13,0x49,0x53,0x14,0x41, 212 0x15,0x16,0x4e,0x55,0x54,0x17,0x18,0x4a,0x4f,0x42,0x19,0x01 213 }; 214 return 0x20+a[random()%N(a)]; 215} 216 217static void | 33 */ 34 35/* 36 * Simple tool for testing hardware/system crypto support. 37 * 38 * cryptotest [-czsbv] [-a algorithm] [count] [size ...] 39 * 40 * Run count iterations of a crypt+decrypt or mac operation on a buffer of --- 169 unchanged lines hidden (view full) --- 210 const char a[] = { 211 0x10,0x54,0x11,0x48,0x45,0x12,0x4f,0x13,0x49,0x53,0x14,0x41, 212 0x15,0x16,0x4e,0x55,0x54,0x17,0x18,0x4a,0x4f,0x42,0x19,0x01 213 }; 214 return 0x20+a[random()%N(a)]; 215} 216 217static void |
218runtest(struct alg *alg, int count, int size, int cmd, struct timeval *tv) | 218runtest(struct alg *alg, int count, int size, u_long cmd, struct timeval *tv) |
219{ 220 int i, fd = crget(); 221 struct timeval start, stop, dt; 222 char *cleartext, *ciphertext, *originaltext; 223 struct session_op sop; 224 struct crypt_op cop; 225 char iv[8]; 226 --- 131 unchanged lines hidden (view full) --- 358#ifdef __FreeBSD__ 359static void 360resetstats() 361{ 362 struct cryptostats stats; 363 size_t slen; 364 365 slen = sizeof (stats); | 219{ 220 int i, fd = crget(); 221 struct timeval start, stop, dt; 222 char *cleartext, *ciphertext, *originaltext; 223 struct session_op sop; 224 struct crypt_op cop; 225 char iv[8]; 226 --- 131 unchanged lines hidden (view full) --- 358#ifdef __FreeBSD__ 359static void 360resetstats() 361{ 362 struct cryptostats stats; 363 size_t slen; 364 365 slen = sizeof (stats); |
366 if (sysctlbyname("kern.crypto_stats", &stats, &slen, NULL, NULL) < 0) { | 366 if (sysctlbyname("kern.crypto_stats", &stats, &slen, NULL, 0) < 0) { |
367 perror("kern.crypto_stats"); 368 return; 369 } 370 bzero(&stats.cs_invoke, sizeof (stats.cs_invoke)); 371 bzero(&stats.cs_done, sizeof (stats.cs_done)); 372 bzero(&stats.cs_cb, sizeof (stats.cs_cb)); 373 bzero(&stats.cs_finis, sizeof (stats.cs_finis)); 374 stats.cs_invoke.min.tv_sec = 10000; --- 15 unchanged lines hidden (view full) --- 390 min = 1000000000LL*ts->min.tv_sec + ts->min.tv_nsec; 391 max = 1000000000LL*ts->max.tv_sec + ts->max.tv_nsec; 392 printf("%16.16s: avg %6llu ns : min %6llu ns : max %7llu ns [%u samps]\n", 393 tag, avg, min, max, ts->count); 394} 395#endif 396 397static void | 367 perror("kern.crypto_stats"); 368 return; 369 } 370 bzero(&stats.cs_invoke, sizeof (stats.cs_invoke)); 371 bzero(&stats.cs_done, sizeof (stats.cs_done)); 372 bzero(&stats.cs_cb, sizeof (stats.cs_cb)); 373 bzero(&stats.cs_finis, sizeof (stats.cs_finis)); 374 stats.cs_invoke.min.tv_sec = 10000; --- 15 unchanged lines hidden (view full) --- 390 min = 1000000000LL*ts->min.tv_sec + ts->min.tv_nsec; 391 max = 1000000000LL*ts->max.tv_sec + ts->max.tv_nsec; 392 printf("%16.16s: avg %6llu ns : min %6llu ns : max %7llu ns [%u samps]\n", 393 tag, avg, min, max, ts->count); 394} 395#endif 396 397static void |
398runtests(struct alg *alg, int count, int size, int cmd, int threads, int profile) | 398runtests(struct alg *alg, int count, int size, u_long cmd, int threads, int profile) |
399{ 400 int i, status; 401 double t; 402 void *region; 403 struct timeval *tvp; 404 struct timeval total; 405 int otiming; 406 --- 49 unchanged lines hidden (view full) --- 456#ifdef __FreeBSD__ 457 if (profile) { 458 struct cryptostats stats; 459 size_t slen = sizeof (stats); 460 461 if (sysctlbyname("debug.crypto_timing", NULL, NULL, 462 &otiming, sizeof (otiming)) < 0) 463 perror("debug.crypto_timing"); | 399{ 400 int i, status; 401 double t; 402 void *region; 403 struct timeval *tvp; 404 struct timeval total; 405 int otiming; 406 --- 49 unchanged lines hidden (view full) --- 456#ifdef __FreeBSD__ 457 if (profile) { 458 struct cryptostats stats; 459 size_t slen = sizeof (stats); 460 461 if (sysctlbyname("debug.crypto_timing", NULL, NULL, 462 &otiming, sizeof (otiming)) < 0) 463 perror("debug.crypto_timing"); |
464 if (sysctlbyname("kern.crypto_stats", &stats, &slen, NULL, NULL) < 0) | 464 if (sysctlbyname("kern.crypto_stats", &stats, &slen, NULL, 0) < 0) |
465 perror("kern.cryptostats"); 466 if (stats.cs_invoke.count) { 467 printt("dispatch->invoke", &stats.cs_invoke); 468 printt("invoke->done", &stats.cs_done); 469 printt("done->cb", &stats.cs_cb); 470 printt("cb->finis", &stats.cs_finis); 471 } 472 } 473#endif 474 fflush(stdout); 475} 476 477int 478main(int argc, char **argv) 479{ 480 struct alg *alg = NULL; 481 int count = 1; 482 int sizes[128], nsizes = 0; | 465 perror("kern.cryptostats"); 466 if (stats.cs_invoke.count) { 467 printt("dispatch->invoke", &stats.cs_invoke); 468 printt("invoke->done", &stats.cs_done); 469 printt("done->cb", &stats.cs_cb); 470 printt("cb->finis", &stats.cs_finis); 471 } 472 } 473#endif 474 fflush(stdout); 475} 476 477int 478main(int argc, char **argv) 479{ 480 struct alg *alg = NULL; 481 int count = 1; 482 int sizes[128], nsizes = 0; |
483 int cmd = CIOCGSESSION; | 483 u_long cmd = CIOCGSESSION; |
484 int testall = 0; 485 int maxthreads = 1; 486 int profile = 0; 487 int i, ch; 488 489 while ((ch = getopt(argc, argv, "cpzsva:bt:")) != -1) { 490 switch (ch) { 491#ifdef CIOCGSSESSION --- 91 unchanged lines hidden --- | 484 int testall = 0; 485 int maxthreads = 1; 486 int profile = 0; 487 int i, ch; 488 489 while ((ch = getopt(argc, argv, "cpzsva:bt:")) != -1) { 490 switch (ch) { 491#ifdef CIOCGSSESSION --- 91 unchanged lines hidden --- |