summaryrefslogtreecommitdiff
path: root/src/sbearssl/sbearssl_skey_from.c
blob: 798b6ed9331b3c7584ac96b49e2180f82aa48cf5 (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_skey_from (sbearssl_skey *l, br_skey const *k, stralloc *sa)
{
  switch (k->type)
  {
    case BR_KEYTYPE_RSA :
      if (!sbearssl_rsa_skey_from(&l->data.rsa, &k->data.rsa, sa)) return 0 ;
      break ;
    case BR_KEYTYPE_EC :
      if (!sbearssl_ec_skey_from(&l->data.ec, &k->data.ec, sa)) return 0 ;
      break ;
    default :
      return 0 ;
  }
  l->type = k->type ;
  return 1 ;
}