From 0e83e72b09744e89c459c8156ac88cb07f35065e Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 9 May 2021 09:06:12 +0100 Subject: [PATCH] New test tool: list-accel.py. Gives a quick and easy report of which HW-accelerated crypto implementations are (a) compiled in to testcrypt, (b) actually instantiable at testcrypt run time. --- test/list-accel.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 test/list-accel.py diff --git a/test/list-accel.py b/test/list-accel.py new file mode 100755 index 00000000..af93d420 --- /dev/null +++ b/test/list-accel.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +# Simple client of the testcrypt system that reports the available +# variants of each of the crypto primitives that have hardware- +# accelerated implementations. +# +# It will report the set of primitives compiled in to testcrypt, and +# also report whether each one can be instantiated at run time. + +from testcrypt import * + +def get_implementations(alg): + return get_implementations_commasep(alg).decode("ASCII").split(",") + +def list_implementations(alg, checkfn): + print(f"Implementations of {alg}:") + for impl in get_implementations(alg): + if impl == alg: + continue + if checkfn(impl): + print(f" {impl:<32s} available") + else: + print(f" {impl:<32s} compiled in, but unavailable at run time") + +def list_cipher_implementations(alg): + list_implementations(alg, lambda impl: ssh_cipher_new(impl) is not None) + +def list_hash_implementations(alg): + list_implementations(alg, lambda impl: ssh_hash_new(impl) is not None) + +list_cipher_implementations("aes256_cbc") +list_hash_implementations("sha1") +list_hash_implementations("sha256") +list_hash_implementations("sha512")