diff options
author | Krzysztof Kwiatkowski <[email protected]> | 2018-01-16 23:01:17 +0000 |
---|---|---|
committer | Krzysztof Kwiatkowski <[email protected]> | 2018-01-21 23:35:27 +0000 |
commit | 45bda8b0429170036ae30ed5d3133011f9e3fe8a (patch) | |
tree | f8be7d45b7995268d9966b59b5f8a5e142f2aef8 /src/lib/ffi/ffi_pkey_algs.cpp | |
parent | 65f375348c0773af6e9bbe3a005aef177dfd4ac3 (diff) |
FFI function for DSA key generation
Adds function for DSA key generation that allows
usage of 'p' and 'q' chosen by the caller.
Diffstat (limited to 'src/lib/ffi/ffi_pkey_algs.cpp')
-rw-r--r-- | src/lib/ffi/ffi_pkey_algs.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/ffi/ffi_pkey_algs.cpp b/src/lib/ffi/ffi_pkey_algs.cpp index 694edfeb3..1a2737834 100644 --- a/src/lib/ffi/ffi_pkey_algs.cpp +++ b/src/lib/ffi/ffi_pkey_algs.cpp @@ -333,6 +333,24 @@ int botan_pubkey_rsa_get_n(botan_mp_t n, botan_pubkey_t key) } /* DSA specific operations */ +int botan_privkey_create_dsa(botan_privkey_t* key, botan_rng_t rng_obj, size_t pbits, size_t qbits) + { +#if defined(BOTAN_HAS_DSA) + + if(rng_obj == nullptr) + return BOTAN_FFI_ERROR_NULL_POINTER; + + return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + Botan::RandomNumberGenerator& rng = safe_get(rng_obj); + Botan::DL_Group group(rng, Botan::DL_Group::Prime_Subgroup, pbits, qbits); + *key = new botan_privkey_struct(new Botan::DSA_PrivateKey(rng, group)); + return BOTAN_FFI_SUCCESS; + }); +#else + BOTAN_UNUSED(key, rng_obj, pbits, qbits); + return BOTAN_FFI_ERROR_NOT_IMPLEMENTED; +#endif + } int botan_privkey_load_dsa(botan_privkey_t* key, botan_mp_t p, botan_mp_t q, botan_mp_t g, botan_mp_t x) |