summaryrefslogtreecommitdiff
path: root/src/sbearssl/sbearssl_choose_hash.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-06-01 11:27:05 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2021-06-01 11:27:05 +0000
commita84b9b4e5d985a5d8a37268a76e1d35210fd31c5 (patch)
tree64cf1b6e3f21e1ac96ea119358fda95091ee6e93 /src/sbearssl/sbearssl_choose_hash.c
parente763c3ef1485404585b923365f93314aab4e8dd6 (diff)
downloads6-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.c20
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 ;
+}