diff options
author | Jack Lloyd <[email protected]> | 2018-08-16 18:53:44 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-08-16 18:53:44 -0400 |
commit | abac219d8a0a48b7d03221cbd9c3f84127acaa01 (patch) | |
tree | 3aee1d5ab75bd6ac763ec574463ca5a0c4cc2c71 /src/lib | |
parent | 4766fb375ab35026389d39547695be2237f6c1ca (diff) |
Add botan_x509_cert_dup
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/ffi/ffi.h | 6 | ||||
-rw-r--r-- | src/lib/ffi/ffi_cert.cpp | 22 |
2 files changed, 24 insertions, 4 deletions
diff --git a/src/lib/ffi/ffi.h b/src/lib/ffi/ffi.h index 27eb8f6d1..a680a0c19 100644 --- a/src/lib/ffi/ffi.h +++ b/src/lib/ffi/ffi.h @@ -1343,6 +1343,8 @@ BOTAN_PUBLIC_API(2,0) int botan_x509_cert_load(botan_x509_cert_t* cert_obj, cons BOTAN_PUBLIC_API(2,0) int botan_x509_cert_load_file(botan_x509_cert_t* cert_obj, const char* filename); BOTAN_PUBLIC_API(2,0) int botan_x509_cert_destroy(botan_x509_cert_t cert); +BOTAN_PUBLIC_API(2,8) int botan_x509_cert_dup(botan_x509_cert_t* new_cert, botan_x509_cert_t cert); + BOTAN_PUBLIC_API(2,0) int botan_x509_cert_gen_selfsigned(botan_x509_cert_t* cert, botan_privkey_t key, @@ -1413,9 +1415,9 @@ BOTAN_PUBLIC_API(2,5) int botan_x509_cert_hostname_match(botan_x509_cert_t cert, BOTAN_PUBLIC_API(2,8) int botan_x509_cert_verify( int* validation_result, botan_x509_cert_t cert, - botan_x509_cert_t* intermediates, + const botan_x509_cert_t* intermediates, size_t intermediates_len, - botan_x509_cert_t* trusted, + const botan_x509_cert_t* trusted, size_t trusted_len, const char* trusted_path, size_t required_strength); diff --git a/src/lib/ffi/ffi_cert.cpp b/src/lib/ffi/ffi_cert.cpp index 20a7ed567..1e832765c 100644 --- a/src/lib/ffi/ffi_cert.cpp +++ b/src/lib/ffi/ffi_cert.cpp @@ -42,6 +42,24 @@ int botan_x509_cert_load_file(botan_x509_cert_t* cert_obj, const char* cert_path #endif } +int botan_x509_cert_dup(botan_x509_cert_t* cert_obj, botan_x509_cert_t cert) + { + if(!cert_obj) + return BOTAN_FFI_ERROR_NULL_POINTER; + +#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM) + + return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + std::unique_ptr<Botan::X509_Certificate> c(new Botan::X509_Certificate(safe_get(cert))); + *cert_obj = new botan_x509_cert_struct(c.release()); + return BOTAN_FFI_SUCCESS; + }); + +#else + return BOTAN_FFI_ERROR_NOT_IMPLEMENTED; +#endif + } + int botan_x509_cert_load(botan_x509_cert_t* cert_obj, const uint8_t cert_bits[], size_t cert_bits_len) { if(!cert_obj || !cert_bits) @@ -238,9 +256,9 @@ int botan_x509_cert_hostname_match(botan_x509_cert_t cert, const char* hostname) int botan_x509_cert_verify(int* result_code, botan_x509_cert_t cert, - botan_x509_cert_t* intermediates, + const botan_x509_cert_t* intermediates, size_t intermediates_len, - botan_x509_cert_t* trusted, + const botan_x509_cert_t* trusted, size_t trusted_len, const char* trusted_path, size_t required_strength) |