summaryrefslogtreecommitdiff
path: root/src/sbearssl/sbearssl_pkey_from.c
blob: e60907e4ec13fbec03a09e5276e18cc80ea6f08e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* ISC license. */

#include <bearssl.h>
#include <s6-networking/sbearssl.h>

int sbearssl_pkey_from (sbearssl_pkey *l, br_x509_pkey const *k, stralloc *sa)
{
  switch (k->key_type)
  {
    case BR_KEYTYPE_RSA :
      if (!sbearssl_rsa_pkey_from(&l->data.rsa, &k->key.rsa, sa)) return 0 ;
      break ;
    case BR_KEYTYPE_EC :
      if (!sbearssl_ec_pkey_from(&l->data.ec, &k->key.ec, sa)) return 0 ;
      break ;
    default :
      return 0 ;
  }
  l->type = k->key_type ;
  return 1 ;
}