aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ffi/ffi.cpp28
-rw-r--r--src/lib/ffi/ffi.h6
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
*/