Skip to content

Commit cede514

Browse files
committed
pkey_ctx: add rsa key generation test
1 parent b46ad6e commit cede514

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

openssl/src/pkey_ctx.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,7 @@ impl<T> PkeyCtxRef<T> {
884884
#[cfg(test)]
885885
mod test {
886886
use super::*;
887+
use crate::bn::BigNum;
887888
#[cfg(not(any(boringssl, awslc)))]
888889
use crate::cipher::Cipher;
889890
use crate::ec::{EcGroup, EcKey};
@@ -1055,6 +1056,18 @@ mod test {
10551056
assert_eq!(params.size(), 72);
10561057
}
10571058

1059+
#[test]
1060+
fn rsa_keygen() {
1061+
let pubexp = BigNum::from_u32(65537).unwrap();
1062+
let mut ctx = PkeyCtx::new_id(Id::RSA).unwrap();
1063+
ctx.keygen_init().unwrap();
1064+
ctx.set_rsa_keygen_pubexp(&pubexp).unwrap();
1065+
ctx.set_rsa_keygen_bits(2048).unwrap();
1066+
let key = ctx.keygen().unwrap();
1067+
1068+
assert_eq!(key.bits(), 2048);
1069+
}
1070+
10581071
#[test]
10591072
#[cfg(any(ossl110, boringssl, libressl360, awslc))]
10601073
fn hkdf() {

0 commit comments

Comments
 (0)