summaryrefslogtreecommitdiff
path: root/src/sbearssl/sbearssl_choose_hash.c
blob: 122808134ec5ebe3ee5303fa63f3b64bf65a9fe2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 ;
}