opnsense-src/tools/tools/crypto
Fabien Thomas f8e73c47d8 Add a SPD cache to speed up lookups.
When large SPDs are used, we face two problems:

- too many CPU cycles are spent during the linear searches in the SPD
  for each packet
- too much contention on multi socket systems, since we use a single
  shared lock.

Main changes:

- added the sysctl tree 'net.key.spdcache' to control the SPD cache
  (disabled by default).
- cache the sp indexes that are used to perform SP lookups.
- use a range of dedicated mutexes to protect the cache lines.

Submitted by: Emeric Poupon <emeric.poupon@stormshield.eu>
Reviewed by: ae
Sponsored by:	Stormshield
Differential Revision: https://reviews.freebsd.org/D15050
2018-05-22 15:54:25 +00:00
..
cryptocheck.c cryptocheck: Add Chacha20 cipher to tool 2018-03-29 04:14:37 +00:00
cryptokeytest.c Overhaul driver/subsystem api's: 2007-03-21 03:42:51 +00:00
cryptorun.sh Add a runner script for cryptotest. 2016-09-02 21:35:32 +00:00
cryptostats.c - Replace N(a)/N(i)/N(T)/LEN(a)/ARRAY_SIZE(a) with nitems() 2015-08-29 19:47:20 +00:00
cryptotest.c cryptotest: Add chacha20 cipher 2018-03-29 04:07:53 +00:00
hifnstats.c - Replace N(a)/N(i)/N(T)/LEN(a)/ARRAY_SIZE(a) with nitems() 2015-08-29 19:47:20 +00:00
ipsecstats.c Add a SPD cache to speed up lookups. 2018-05-22 15:54:25 +00:00
Makefile cryptocheck: Add support for Blake2{B,S} hashes 2018-03-23 05:37:18 +00:00
README
safestats.c - Replace N(a)/N(i)/N(T)/LEN(a)/ARRAY_SIZE(a) with nitems() 2015-08-29 19:47:20 +00:00
ubsecstats.c - Replace N(a)/N(i)/N(T)/LEN(a)/ARRAY_SIZE(a) with nitems() 2015-08-29 19:47:20 +00:00

$FreeBSD$

The cryptotest program repeatedly encrypts and decrypts a buffer
with the built-in iv and key, using hardware crypto.  At the end,
it computes the data rate achieved.  Operations are carried out by
making ioctl calls to /dev/crypto.

For a test of how fast a crypto card is, use something like:

	cryptotest -z 1024

This will run a series of tests using the available crypto/cipher
algorithms over a variety of buffer sizes.  The 1024 says to do
1024 iterations.  Extra arguments can be used to specify one or
more buffer sizes to use in doing tests.

A sample run is:

 0.129 sec,    2048    des crypts,       8 bytes,   127120 byte/sec,     1.0 Mb/sec
 0.129 sec,    2048    des crypts,      16 bytes,   253915 byte/sec,     1.9 Mb/sec
 0.129 sec,    2048    des crypts,      32 bytes,   508942 byte/sec,     3.9 Mb/sec
 0.128 sec,    2048    des crypts,      64 bytes,  1020135 byte/sec,     7.8 Mb/sec
 0.134 sec,    2048    des crypts,     128 bytes,  1954869 byte/sec,    14.9 Mb/sec
 0.142 sec,    2048    des crypts,     256 bytes,  3698107 byte/sec,    28.2 Mb/sec
 0.190 sec,    2048    des crypts,    1024 bytes, 11037700 byte/sec,    84.2 Mb/sec
 0.264 sec,    2048    des crypts,    2048 bytes, 15891127 byte/sec,   121.2 Mb/sec
 0.403 sec,    2048    des crypts,    4096 bytes, 20828998 byte/sec,   158.9 Mb/sec
 0.687 sec,    2048    des crypts,    8192 bytes, 24426602 byte/sec,   186.4 Mb/sec
 0.129 sec,    2048   3des crypts,       8 bytes,   127321 byte/sec,     1.0 Mb/sec
 0.131 sec,    2048   3des crypts,      16 bytes,   249773 byte/sec,     1.9 Mb/sec
 0.128 sec,    2048   3des crypts,      32 bytes,   512304 byte/sec,     3.9 Mb/sec
 0.128 sec,    2048   3des crypts,      64 bytes,  1021685 byte/sec,     7.8 Mb/sec
 0.132 sec,    2048   3des crypts,     128 bytes,  1986511 byte/sec,    15.2 Mb/sec
 0.142 sec,    2048   3des crypts,     256 bytes,  3695005 byte/sec,    28.2 Mb/sec
 0.190 sec,    2048   3des crypts,    1024 bytes, 11024876 byte/sec,    84.1 Mb/sec
 0.264 sec,    2048   3des crypts,    2048 bytes, 15887997 byte/sec,   121.2 Mb/sec
 0.402 sec,    2048   3des crypts,    4096 bytes, 20850846 byte/sec,   159.1 Mb/sec
 0.689 sec,    2048   3des crypts,    8192 bytes, 24333532 byte/sec,   185.7 Mb/sec

Expect ~400 Mb/s for a Broadcom 582x for 16K buffers on a reasonable
CPU.  Hifn 7811 parts top out at ~120 Mb/s.  Performance depends
heavily on memory and bus performance.

This code originally came from openbsd; give them all the credit.