Skip to content

Commit

Permalink
move kyber functions into the botan3 feature
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkjall committed May 27, 2023
1 parent d8b0f94 commit 8d404c1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
29 changes: 24 additions & 5 deletions botan-sys/src/pubkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
5 changes: 4 additions & 1 deletion botan/src/pubkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ impl Privkey {
Ok(Privkey { obj })
}

#[cfg(feature = "botan3")]
/// Load a kyber private key
///
/// # Examples
Expand All @@ -110,7 +111,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<Privkey> {
let obj = botan_init!(botan_privkey_load_kyber, key.as_ptr(), key.len())?;
Ok(Privkey { obj })
Expand Down Expand Up @@ -459,6 +459,7 @@ impl Privkey {
Ok(out)
}

#[cfg(feature = "botan3")]
/// Get the Kyber private key
///
/// # Examples
Expand Down Expand Up @@ -614,6 +615,7 @@ impl Pubkey {
Ok(Pubkey { obj })
}

#[cfg(feature = "botan3")]
/// Load an Kyber key
///
/// # Examples
Expand Down Expand Up @@ -749,6 +751,7 @@ impl Pubkey {
Ok(out)
}

#[cfg(feature = "botan3")]
/// Get an Kyber key
///
/// # Examples
Expand Down

0 comments on commit 8d404c1

Please sign in to comment.