File: list-accel.py

package info (click to toggle)
putty 0.83-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,216 kB
  • sloc: ansic: 148,476; python: 8,466; perl: 1,830; makefile: 128; sh: 117
file content (38 lines) | stat: -rwxr-xr-x 1,309 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/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_mac_implementations(alg):
    list_implementations(alg, lambda impl: ssh2_mac_new(impl, None) 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_mac_implementations("aesgcm")
list_hash_implementations("sha1")
list_hash_implementations("sha256")
list_hash_implementations("sha512")