diff options
Diffstat (limited to 'src/lib/crypt.c')
-rw-r--r-- | src/lib/crypt.c | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/src/lib/crypt.c b/src/lib/crypt.c index 756fcccc..e8c4d5ab 100644 --- a/src/lib/crypt.c +++ b/src/lib/crypt.c @@ -60,10 +60,13 @@ int crypt_dh_pkp_create(void ** pkp, void crypt_dh_pkp_destroy(void * pkp) { + if (pkp == NULL) + return; #ifdef HAVE_OPENSSL openssl_ecdh_pkp_destroy(pkp); #else (void) pkp; + return; #endif } @@ -179,7 +182,7 @@ int crypt_load_privkey_file(const char * path, } int crypt_load_privkey_str(const char * str, - void ** key) + void ** key) { *key = NULL; @@ -232,6 +235,8 @@ void crypt_free_key(void * key) int crypt_load_crt_file(const char * path, void ** crt) { + assert(crt != NULL); + *crt = NULL; #ifdef HAVE_OPENSSL @@ -246,6 +251,8 @@ int crypt_load_crt_file(const char * path, int crypt_load_crt_str(const char * str, void ** crt) { + assert(crt != NULL); + *crt = NULL; #ifdef HAVE_OPENSSL @@ -257,6 +264,21 @@ int crypt_load_crt_str(const char * str, #endif } +int crypt_load_crt_der(const buffer_t buf, + void ** crt) +{ + assert(crt != NULL); +#ifdef HAVE_OPENSSL + return openssl_load_crt_der(buf, crt); +#else + *crt = NULL; + + (void) buf; + + return 0; +#endif +} + int crypt_get_pubkey_crt(void * crt, void ** pk) { @@ -283,8 +305,8 @@ void crypt_free_crt(void * crt) #endif } -int crypt_crt_str(void * crt, - char * buf) +int crypt_crt_str(const void * crt, + char * buf) { #ifdef HAVE_OPENSSL return openssl_crt_str(crt, buf); @@ -296,6 +318,23 @@ int crypt_crt_str(void * crt, #endif } +int crypt_crt_der(const void * crt, + buffer_t * buf) +{ + assert(crt != NULL); + assert(buf != NULL); + +#ifdef HAVE_OPENSSL + return openssl_crt_der(crt, buf); +#else + (void) crt; + + clrbuf(*buf); + + return 0; +#endif +} + int crypt_check_crt_name(void * crt, const char * name) { |