From owner-svn-src-head@freebsd.org Tue Aug 30 14:28:36 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31DBFBC847E; Tue, 30 Aug 2016 14:28:36 +0000 (UTC) (envelope-from gnn@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0D1C7D8E; Tue, 30 Aug 2016 14:28:35 +0000 (UTC) (envelope-from gnn@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u7UESZQn005907; Tue, 30 Aug 2016 14:28:35 GMT (envelope-from gnn@FreeBSD.org) Received: (from gnn@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u7UESZKQ005906; Tue, 30 Aug 2016 14:28:35 GMT (envelope-from gnn@FreeBSD.org) Message-Id: <201608301428.u7UESZKQ005906@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gnn set sender to gnn@FreeBSD.org using -f From: "George V. Neville-Neil" Date: Tue, 30 Aug 2016 14:28:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r305066 - head/tools/tools/crypto X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2016 14:28:36 -0000 Author: gnn Date: Tue Aug 30 14:28:35 2016 New Revision: 305066 URL: https://svnweb.freebsd.org/changeset/base/305066 Log: Update cryptotest for modern algorithms Reviewed by: cem Sponsored by: Rubicon Communications, LLC (Netgate) Differential Revision: https://reviews.freebsd.org/D7598 Modified: head/tools/tools/crypto/cryptotest.c Modified: head/tools/tools/crypto/cryptotest.c ============================================================================== --- head/tools/tools/crypto/cryptotest.c Tue Aug 30 14:09:24 2016 (r305065) +++ head/tools/tools/crypto/cryptotest.c Tue Aug 30 14:28:35 2016 (r305066) @@ -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 } #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 cryptotst } #endif -static void +void runtests(struct alg *alg, int count, int size, u_long cmd, int threads, int profile) { int i, status;