Update cryptotest for modern algorithms
Reviewed by: cem Sponsored by: Rubicon Communications, LLC (Netgate) Differential Revision: https://reviews.freebsd.org/D7598
This commit is contained in:
parent
b2af61ec69
commit
66096993b4
@ -126,9 +126,10 @@ struct alg {
|
||||
{ "blf", 0, 8, 5, 56, CRYPTO_BLF_CBC },
|
||||
{ "cast", 0, 8, 5, 16, CRYPTO_CAST_CBC },
|
||||
{ "skj", 0, 8, 10, 10, CRYPTO_SKIPJACK_CBC },
|
||||
{ "aes", 0, 16, 16, 16, CRYPTO_RIJNDAEL128_CBC},
|
||||
{ "aes192", 0, 16, 24, 24, CRYPTO_RIJNDAEL128_CBC},
|
||||
{ "aes256", 0, 16, 32, 32, CRYPTO_RIJNDAEL128_CBC},
|
||||
{ "rij", 0, 16, 16, 16, CRYPTO_RIJNDAEL128_CBC},
|
||||
{ "aes", 0, 16, 16, 16, CRYPTO_AES_CBC},
|
||||
{ "aes192", 0, 16, 24, 24, CRYPTO_AES_CBC},
|
||||
{ "aes256", 0, 16, 32, 32, CRYPTO_AES_CBC},
|
||||
#ifdef notdef
|
||||
{ "arc4", 0, 8, 1, 32, CRYPTO_ARC4 },
|
||||
#endif
|
||||
@ -139,19 +140,20 @@ struct alg {
|
||||
{ "sha512", 1, 8, 64, 64, CRYPTO_SHA2_512_HMAC },
|
||||
};
|
||||
|
||||
static void
|
||||
void
|
||||
usage(const char* cmd)
|
||||
{
|
||||
printf("usage: %s [-czsbv] [-d dev] [-a algorithm] [count] [size ...]\n",
|
||||
cmd);
|
||||
printf("where algorithm is one of:\n");
|
||||
printf(" des 3des (default) blowfish cast skipjack\n");
|
||||
printf(" aes (aka rijndael) aes192 aes256 arc4\n");
|
||||
printf(" des 3des (default) blowfish cast skipjack rij\n");
|
||||
printf(" aes aes192 aes256 arc4\n");
|
||||
printf("count is the number of encrypt/decrypt ops to do\n");
|
||||
printf("size is the number of bytes of text to encrypt+decrypt\n");
|
||||
printf("\n");
|
||||
printf("-c check the results (slows timing)\n");
|
||||
printf("-d use specific device\n");
|
||||
printf("-d use specific device, specify 'soft' for testing software implementations\n");
|
||||
printf("\tNOTE: to use software you must set:\n\t sysctl kern.cryptodevallowsoft=1\n");
|
||||
printf("-z run all available algorithms on a variety of sizes\n");
|
||||
printf("-v be verbose\n");
|
||||
printf("-b mark operations for batching\n");
|
||||
@ -159,7 +161,7 @@ usage(const char* cmd)
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
static struct alg*
|
||||
struct alg*
|
||||
getalgbycode(int cipher)
|
||||
{
|
||||
int i;
|
||||
@ -170,7 +172,7 @@ getalgbycode(int cipher)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct alg*
|
||||
struct alg*
|
||||
getalgbyname(const char* name)
|
||||
{
|
||||
int i;
|
||||
@ -181,10 +183,10 @@ getalgbyname(const char* name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
devcrypto(void)
|
||||
{
|
||||
static int fd = -1;
|
||||
int fd = -1;
|
||||
|
||||
if (fd < 0) {
|
||||
fd = open(_PATH_DEV "crypto", O_RDWR, 0);
|
||||
@ -196,11 +198,14 @@ devcrypto(void)
|
||||
return fd;
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
crlookup(const char *devname)
|
||||
{
|
||||
struct crypt_find_op find;
|
||||
|
||||
if (strncmp(devname, "soft", 4) == 0)
|
||||
return CRYPTO_FLAG_SOFTWARE;
|
||||
|
||||
find.crid = -1;
|
||||
strlcpy(find.name, devname, sizeof(find.name));
|
||||
if (ioctl(devcrypto(), CIOCFINDDEV, &find) == -1)
|
||||
@ -208,10 +213,10 @@ crlookup(const char *devname)
|
||||
return find.crid;
|
||||
}
|
||||
|
||||
static const char *
|
||||
const char *
|
||||
crfind(int crid)
|
||||
{
|
||||
static struct crypt_find_op find;
|
||||
struct crypt_find_op find;
|
||||
|
||||
bzero(&find, sizeof(find));
|
||||
find.crid = crid;
|
||||
@ -220,7 +225,7 @@ crfind(int crid)
|
||||
return find.name;
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
crget(void)
|
||||
{
|
||||
int fd;
|
||||
@ -232,7 +237,7 @@ crget(void)
|
||||
return fd;
|
||||
}
|
||||
|
||||
static char
|
||||
char
|
||||
rdigit(void)
|
||||
{
|
||||
const char a[] = {
|
||||
@ -242,7 +247,7 @@ rdigit(void)
|
||||
return 0x20+a[random()%nitems(a)];
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
runtest(struct alg *alg, int count, int size, u_long cmd, struct timeval *tv)
|
||||
{
|
||||
int i, fd = crget();
|
||||
@ -386,7 +391,7 @@ runtest(struct alg *alg, int count, int size, u_long cmd, struct timeval *tv)
|
||||
}
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
static void
|
||||
void
|
||||
resetstats()
|
||||
{
|
||||
struct cryptostats stats;
|
||||
@ -409,7 +414,7 @@ resetstats()
|
||||
perror("kern.cryptostats");
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
printt(const char* tag, struct cryptotstat *ts)
|
||||
{
|
||||
uint64_t avg, min, max;
|
||||
@ -424,7 +429,7 @@ printt(const char* tag, struct cryptotstat *ts)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
void
|
||||
runtests(struct alg *alg, int count, int size, u_long cmd, int threads, int profile)
|
||||
{
|
||||
int i, status;
|
||||
|
Loading…
Reference in New Issue
Block a user