diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2016-11-25 18:16:05 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2016-11-25 18:16:05 +0000 |
commit | 018025f0f36a4847df265c9948dbaf7073ed3245 (patch) | |
tree | 984c9a4bba06ef8abc02d0fbe81a70ec28c6f529 /src/sbearssl/sbearssl_skey_from.c | |
parent | 6421a5e923b0f695047b429e4176bca2873c5189 (diff) | |
download | s6-networking-018025f0f36a4847df265c9948dbaf7073ed3245.tar.xz |
Alpha version of the SSL work.
Doesn't build yet, but I'm scared of losing it, so using git as
storage.
Will fix the stupid bugs now, the tricky bugs later.
Diffstat (limited to 'src/sbearssl/sbearssl_skey_from.c')
-rw-r--r-- | src/sbearssl/sbearssl_skey_from.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/sbearssl/sbearssl_skey_from.c b/src/sbearssl/sbearssl_skey_from.c new file mode 100644 index 0000000..26b2788 --- /dev/null +++ b/src/sbearssl/sbearssl_skey_from.c @@ -0,0 +1,23 @@ +/* ISC license. */ + +#include <errno.h> +#include <bearssl.h> +#include <skalibs/stralloc.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_pkey_from(&l->data.ec, &k->data.ec, sa) return 0 ; + break ; + default : + return (errno = EINVAL, 0) ; + } + l->type = k->type ; + return 1 ; +} |