From 125e38c8aadf6dc606e8c0ed377058e05c3a52e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Kj=C3=A4ll?= Date: Sat, 27 May 2023 16:37:31 +0200 Subject: [PATCH] move kyber functions into the botan3 feature --- botan-sys/src/pubkey.rs | 29 ++++++++++++++++++++++++----- botan/src/pubkey.rs | 5 ++++- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/botan-sys/src/pubkey.rs b/botan-sys/src/pubkey.rs index edc042a..ac1359a 100644 --- a/botan-sys/src/pubkey.rs +++ b/botan-sys/src/pubkey.rs @@ -211,11 +211,6 @@ extern "C" { pub fn botan_privkey_x25519_get_privkey(key: botan_privkey_t, output: *mut u8) -> c_int; pub fn botan_pubkey_x25519_get_pubkey(key: botan_pubkey_t, pubkey: *mut u8) -> c_int; - pub fn botan_privkey_load_kyber(key: *mut botan_privkey_t, privkey: *const u8, key_len: usize) -> c_int; - pub fn botan_pubkey_load_kyber(key: *mut botan_pubkey_t, privkey: *const u8, key_len: usize) -> c_int; - pub fn botan_privkey_view_kyber_raw_key(key: botan_privkey_t, ctx: botan_view_ctx, view: botan_view_bin_fn) -> c_int; - pub fn botan_pubkey_view_kyber_raw_key(key: botan_pubkey_t, ctx: botan_view_ctx, view: botan_view_bin_fn) -> c_int; - pub fn botan_privkey_load_ecdsa( key: *mut botan_privkey_t, scalar: botan_mp_t, @@ -322,4 +317,28 @@ extern "C" { view_ctx: botan_view_ctx, view_fn: botan_view_str_fn, ) -> c_int; + + pub fn botan_privkey_load_kyber( + key: *mut botan_privkey_t, + privkey: *const u8, + key_len: usize + ) -> c_int; + + pub fn botan_pubkey_load_kyber( + key: *mut botan_pubkey_t, + privkey: *const u8, + key_len: usize + ) -> c_int; + + pub fn botan_privkey_view_kyber_raw_key( + key: botan_privkey_t, + ctx: botan_view_ctx, view: + botan_view_bin_fn + ) -> c_int; + + pub fn botan_pubkey_view_kyber_raw_key( + key: botan_pubkey_t, + ctx: botan_view_ctx, + view: botan_view_bin_fn + ) -> c_int; } diff --git a/botan/src/pubkey.rs b/botan/src/pubkey.rs index e2fc479..9cf7ae4 100644 --- a/botan/src/pubkey.rs +++ b/botan/src/pubkey.rs @@ -109,6 +109,7 @@ impl Privkey { Ok(Privkey { obj }) } + #[cfg(feature = "botan3")] /// Load a kyber private key /// /// # Examples @@ -132,7 +133,6 @@ impl Privkey { /// let v = vec![0x42; 1631]; /// let key512 = botan::Privkey::load_kyber(&v).unwrap(); /// ``` - #[cfg(feature = "botan3")] pub fn load_kyber(key: &[u8]) -> Result { let obj = botan_init!(botan_privkey_load_kyber, key.as_ptr(), key.len())?; Ok(Privkey { obj }) @@ -484,6 +484,7 @@ impl Privkey { Ok(out) } + #[cfg(feature = "botan3")] /// Get the Kyber private key /// /// # Examples @@ -639,6 +640,7 @@ impl Pubkey { Ok(Pubkey { obj }) } + #[cfg(feature = "botan3")] /// Load an Kyber key /// /// # Examples @@ -774,6 +776,7 @@ impl Pubkey { Ok(out) } + #[cfg(feature = "botan3")] /// Get an Kyber key /// /// # Examples