diff options
author | Krzysztof Kwiatkowski <[email protected]> | 2017-06-10 16:28:29 +0100 |
---|---|---|
committer | Krzysztof Kwiatkowski <[email protected]> | 2017-06-10 16:28:29 +0100 |
commit | 30568fc980e64d8692e1bb747d5b26f6ab62d1bb (patch) | |
tree | 3db1aa14644e01d38d9720f319763f8bc6346d6b /src/lib/ffi | |
parent | 904cd4fe1ce7f88873891e5cb8a0ed32cec8925b (diff) |
FFI: Posibility to load EC pubkey
Diffstat (limited to 'src/lib/ffi')
-rw-r--r-- | src/lib/ffi/ffi.cpp | 28 | ||||
-rw-r--r-- | src/lib/ffi/ffi.h | 6 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/lib/ffi/ffi.cpp b/src/lib/ffi/ffi.cpp index 3803e5dd6..f72ba180a 100644 --- a/src/lib/ffi/ffi.cpp +++ b/src/lib/ffi/ffi.cpp @@ -1703,7 +1703,7 @@ int botan_privkey_load_ec(botan_privkey_t* key, const botan_mp_t scalar, const char* curve_name) { -#if defined(BOTAN_HAS_ECDSA) +#if defined(BOTAN_HAS_ECC_PUBLIC_KEY_CRYPTO) *key = nullptr; try { @@ -1723,6 +1723,32 @@ int botan_privkey_load_ec(botan_privkey_t* key, #endif } +BOTAN_DLL int botan_pubkey_load_ec(botan_pubkey_t* key, + const botan_mp_t public_x, + const botan_mp_t public_y, + const char* curve_name) + { +#if defined(BOTAN_HAS_ECC_PUBLIC_KEY_CRYPTO) + *key = nullptr; + try + { + Botan::Null_RNG null_rng; + Botan::EC_Group grp(curve_name); + Botan::PointGFp uncompressed_point(grp.get_curve(), safe_get(public_x), safe_get(public_y)); + *key = new botan_pubkey_struct(new Botan::ECDSA_PublicKey(grp, uncompressed_point)); + return 0; + } + catch(std::exception& e) + { + log_exception(BOTAN_CURRENT_FUNCTION, e.what()); + } + return -1; +#else + BOTAN_UNUSED(key, public_x, public_y, curve_name); + return BOTAN_FFI_ERROR_NOT_IMPLEMENTED; +#endif + } + int botan_pubkey_get_field(botan_mp_t output, botan_pubkey_t key, const char* field_name_cstr) diff --git a/src/lib/ffi/ffi.h b/src/lib/ffi/ffi.h index 206b749b2..e5a399bbd 100644 --- a/src/lib/ffi/ffi.h +++ b/src/lib/ffi/ffi.h @@ -868,6 +868,12 @@ BOTAN_DLL int botan_privkey_load_ec(botan_privkey_t* key, const botan_mp_t scalar, const char* curve_name); + +BOTAN_DLL int botan_pubkey_load_ec(botan_pubkey_t* key, + const botan_mp_t x, + const botan_mp_t y, + const char* curve_name); + /* * Public Key Encryption */ |