diff options
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 ; +} |