diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2021-06-01 11:27:05 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2021-06-01 11:27:05 +0000 |
commit | a84b9b4e5d985a5d8a37268a76e1d35210fd31c5 (patch) | |
tree | 64cf1b6e3f21e1ac96ea119358fda95091ee6e93 /src/sbearssl/sbearssl_choose_hash.c | |
parent | e763c3ef1485404585b923365f93314aab4e8dd6 (diff) | |
download | s6-networking-a84b9b4e5d985a5d8a37268a76e1d35210fd31c5.tar.xz |
Add all the missing pieces for sni_policy
sbearssl_server_init_and_run is yet unchanged, the next step
is to rewrite it using the new primitives.
Diffstat (limited to 'src/sbearssl/sbearssl_choose_hash.c')
-rw-r--r-- | src/sbearssl/sbearssl_choose_hash.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/sbearssl/sbearssl_choose_hash.c b/src/sbearssl/sbearssl_choose_hash.c new file mode 100644 index 0000000..1228081 --- /dev/null +++ b/src/sbearssl/sbearssl_choose_hash.c @@ -0,0 +1,20 @@ +/* ISC license. */ + +#include <bearssl.h> + +#include "sbearssl-internal.h" + +unsigned int sbearssl_choose_hash (unsigned int bf) +{ + static unsigned char const pref[5] = + { + br_sha256_ID, + br_sha384_ID, + br_sha512_ID, + br_sha224_ID, + br_sha1_ID + } ; + for (unsigned int i = 0 ; i < 5 ; i++) + if ((bf >> pref[i]) & 1) return pref[i] ; + return 0 ; +} |