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 Oct 31, 2023
1 parent bc2aa67 commit 125e38c
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 @@ -109,6 +109,7 @@ impl Privkey {
Ok(Privkey { obj })
}

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

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

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

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

0 comments on commit 125e38c

Please sign in to comment.