diff options
author | Jack Lloyd <[email protected]> | 2018-07-04 17:52:44 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-07-04 17:52:44 -0400 |
commit | 26b2bdc110cb088eb2e29166f3ef11d47620e0e3 (patch) | |
tree | 50544a81c729634b21c68c1471dd3238ac80c414 /src/lib/ffi/ffi_pkey_algs.cpp | |
parent | ad45110c607efe73590e265a336a02f113e027c8 (diff) |
Small post-merge fixups of #1621
Formatting, and fix the API revision annotations
Adds pem as explicit dependency to FFI; already pubkey pulls it in
but good to be explicit.
Diffstat (limited to 'src/lib/ffi/ffi_pkey_algs.cpp')
-rw-r--r-- | src/lib/ffi/ffi_pkey_algs.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/lib/ffi/ffi_pkey_algs.cpp b/src/lib/ffi/ffi_pkey_algs.cpp index 46c7e28d5..d9388afee 100644 --- a/src/lib/ffi/ffi_pkey_algs.cpp +++ b/src/lib/ffi/ffi_pkey_algs.cpp @@ -285,17 +285,16 @@ int botan_privkey_load_rsa(botan_privkey_t* key, } int botan_privkey_load_rsa_pkcs1(botan_privkey_t* key, - const uint8_t bits[], - size_t len) + const uint8_t bits[], + size_t len) { #if defined(BOTAN_HAS_RSA) *key = nullptr; Botan::secure_vector<uint8_t> src(bits, bits + len); return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { - *key = new botan_privkey_struct(new Botan::RSA_PrivateKey(Botan::AlgorithmIdentifier("RSA", - Botan::AlgorithmIdentifier::USE_NULL_PARAM), - src)); + Botan::AlgorithmIdentifier alg_id("RSA", Botan::AlgorithmIdentifier::USE_NULL_PARAM); + *key = new botan_privkey_struct(new Botan::RSA_PrivateKey(alg_id, src)); return BOTAN_FFI_SUCCESS; }); #else @@ -355,13 +354,13 @@ int botan_pubkey_rsa_get_n(botan_mp_t n, botan_pubkey_t key) } int botan_privkey_rsa_get_privkey(botan_privkey_t rsa_key, - uint8_t out[], size_t* out_len, - uint32_t flags) + uint8_t out[], size_t* out_len, + uint32_t flags) { #if defined(BOTAN_HAS_RSA) return BOTAN_FFI_DO(Botan::Private_Key, rsa_key, k, { if(const Botan::RSA_PrivateKey* rsa = dynamic_cast<const Botan::RSA_PrivateKey*>(&k)) - { + { if(flags == BOTAN_PRIVKEY_EXPORT_FLAG_DER) return write_vec_output(out, out_len, rsa->private_key_bits()); else if(flags == BOTAN_PRIVKEY_EXPORT_FLAG_PEM) @@ -369,12 +368,12 @@ int botan_privkey_rsa_get_privkey(botan_privkey_t rsa_key, "RSA PRIVATE KEY")); else return BOTAN_FFI_ERROR_BAD_FLAG; - } + } else - { + { return BOTAN_FFI_ERROR_BAD_PARAMETER; - } - }); + } + }); #else BOTAN_UNUSED(rsa_key, out, out_len); return BOTAN_FFI_ERROR_NOT_IMPLEMENTED; |