Skip to content

Commit

Permalink
tests: Replace invalid key
Browse files Browse the repository at this point in the history
The rsa4096pkcs_inject test is broken with rsa v0.9.7 because it uses an
invalid key.  This patch replaces the invalid key with a valid key
generated with the Python cryptography package:

    from cryptography.hazmat.primitives.asymmetric import rsa

    e = int("010001", 16)
    private_key = rsa.generate_private_key(e, 4096)
    public_numbers = private_key.public_key().public_numbers()
    private_numbers = private_key.private_numbers()
    print(f"n = {hex(public_numbers.n)}")
    print(f"e = {hex(public_numbers.e)}")
    print(f"d = {hex(private_numbers.d)}")
    print(f"p = {hex(private_numbers.p)}")
    print(f"q = {hex(private_numbers.q)}")

Fixes: #15
  • Loading branch information
robin-nitrokey committed Jan 7, 2025
1 parent 655eca3 commit a3b481d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/rsa4096.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ fn rsa4096pkcs_sign_verify() {
#[test_log::test]
fn rsa4096pkcs_inject() {
virt::with_ram_client("rsa test", |mut client| {
let n = hex!("adc511a420f48ffcb2c62f1a5113fe4e7f3efa20b0c6e711b93aca7e5ad662ba089ac27e9a1ae4cda8032d0b1ec8e3f719f6d3a04e1572a35caec922b439d53324b020d07e3ff70de2fb53409d26af1034b8f8fbf3776b1decd515af1298d98a671e3b2fd871f1b38c8917ed15c8732f96f75166df782d190913653a21da5d0647abc63c5b157910c455a4ac10d8ca3123ccdb98baf947e3a9ab9bff34fa9b0a19ab61f82c560ca46bad10391e49ef2bf5f01f198db12225338d68b0b18eaab962686e6a445b943952981fdf4c6f8135b6e86b1658d930df7fc2288c178401784a90977d1cf4444b401dabe2ebc6448979f74930aab7933a2fadc4c7b96c2fc65e85b2c49f0fa48381928ba64466b7c13303f8fa4b4afd5ad98e9d0990211a2b80caf6b071301e63d9f46b5d52016ec239e983efc1f6a0cd39a1fb9ae91483cc63f1467d13550802aab45ee03223ab1c13bdd82d79c4575f1bc4179ee9d7183534dd27b0a240497b951338fd29f863ff769140a4251219e61ef1ec8274d48431b58f7201c9069499488ac6c9e13e1ed790df14987760ef568a9fae55fd14e4e85232a345e265fb0ace01a0dc10a5390f67c9dba1de7d90b5b542eaaa370d935e153c97e82fe5108d9065991ad65181b2a2136d1474f91b3b85167cd3c04bdc6d144c4034b96b6be93b33c6d14bb511ffc04659cf807cbfd5039f68fb2ebe8ae9");
let n = hex!("b1cb5aa27a7a8d7b1bb3d0e483be1a04f44c47f0a527814d1681b44fca112cce1a6a62acee4023a27e9208c9afd7bcc5e703cda2e97b5ed32b2b528731ce824e4ad80c6bed565490df84643476f7c8e857682ed0d6c0b4ba3287f26489e9b00469cacbdfd00c90940869762f13d35878ea7aab04b454a2bd3cb2dd3ccc9d51cda24ca199fc6d30005bde0f238cdcd5e21f6709a19275522b39fef15e3a7faa166494abe50ac49fc769a8bcd32d09bba70f6769fa5ecc008a7d5a51a3365f50a13b6e2dee2c961553fd01c5829b012caebf3aa9db46252a0d4f9278302b69bc21ea97ee6dae0fad3a0a82d5b522ef7d9cf308abd79dc462ccfc317d83a4f43541c752c858528adf5e0a7252965782dd6b48941987515641625385c9a1024811d35091fcead599a4b54584cb79e7ce7a336504e79c37540b176eafa2ba57a7e1aea12e8f7aee12ee256570968ae758b2ba5cc684c0d6c798fca822ac8e1cf72b0fba689582de6f0555b6f6b9552ceec2902153f5061a0a4be19401dc097181eec9cf6d8e2c624888c6c8b3f25663f8b5a74512d00aa1b57af70cf93485d033e55f3ce4137ef1158854e7bbcc1adec2c26c2233d4c21fc7cc4d9eb96ff8c6662be9775a75059277b1fe932141ea7325b2877393d21e934ead08e065134edb59d8c3156da6d9a429291adbddcce85ba91977e4d5e93f223c04ecbfcfbabcc6c5463f");
let e = hex!("010001");
let d = hex!("974447d9127f12a0ad976c0582b2dedbc255363422eee2d340e576c48b9ab892ad4edb248e4dff032fd0a3f35c37108b5864cf506ae8acc49cb7e28b7d4c22d5c48835e8891e7197fb114125ac27b2996eebde82a52c3d68ed7388cec067a267a2e06431803fa061e662a91b4fad10e84a88bca9cabab8b7647927d37508bb95edea1045161d19288960ec5a84c7d32af7b92b28470b1d93876dc5fc61480e92ba49c09ce32b7d11dc51e91f6fc87895522057524d4ff7235f3f27f5387bb30e7225ea88433d5d489127b0071868b097ebc363052f0ed2469cd68da9760709a887705b0f249756");
let d = hex!("30730ce0c7e58b9667a7299e8bf40add1cc188bd201452dcf1ec2879b1c3da64d3b7f7e9ce06f66efa74cb2642dfd4564dacb0a5db603e27e754a7e9a57df3ee67e0d609b7245669202fd0aaa75cc087e801c0f831fd538285f09bf21fcee9a35a3ce42fba5f222ae4dbf053c5e04af4b058fb2f8e009e54592d18b2cfc3731e4942feaa9aaa1a718e9745a2d768fa73e340cdd414b819cb23c3c07c800e780820228f711bed16e95d7698f62708c6f530726ae3ca5f672a561c7db0af496c0c73c88385aaeabf2723040f9196b1cc3e5668230f58df19c584d09225f63e9b00d70fcdee5f87701a27f11d517e12ab3550d92512ddb03d8844952bf1eaca8d94495c07c3a998ca9ca358aa284d3876d3e0105f0bca15a5f2f798fdf1b30d4140817727d73b5ff42683b37dbba911133770586090f21df022c4685026b1cd21cd55e098dc2b9b30d4bb28b7f36db53e8851d0bedc66bfcceaf4592d634ae1d88d1d21987ba7983bada4c64b57acda4394b58237c10e4c29bb70351732cdc412a621512cddfd1b8025091aa4fb5d4180d1ee5781cdd2ebe0a9426ffc790ad941beb676506026885f2c7a0c827899427ef1fc280e7786b6a88f17d8ec5f7bd99339f03add6113cc8ce3496d209d237efa0878c3f13dfafbaf6bc8909a50522019f87d56daf1900e7eb1b41c1d8ec2487c0040ee07ac6b493632b7846c04bd4762b9");

let p1 = hex!("cb4b267410739733134e5c7d21f042db821d3bf1e20b036de71cb40f175b3ddc8a164155223c5fec1df598fd5c314e9bc622c9c01fb3c70b1712b9f77d2ed6de5e9fe5b6dbfd789cedff5acff7d2bf0587bc071d43552f671e5392f69f7b16820bc2bec80b28f1eb42bbf2b99bd31eab59c479d2cd66550a7cf8d000b1c0e9c82460791a722bcd1945e134180b94ebf52026f0ee731cc63c38958f2fa5049ddac4cf55f57240f98afc51ff21a3379b16eba3974bb70623ec06afe6cd2d26041611c7b3b799090103fc0df8973aa1919a2ae65ccd1f484ccc5da4975ace0e96a2c3c0001c9b293b908d5585da5c0bb61ff5c17c20a0bd946a8df4fb7dd98cb44d");
let p2 = hex!("dad263cb9b3c236859da7ecc6ec5f2154404dedf07cf39c7fd80ec2206384e906f001cf42ca690ab59a2aa73a2c78dfa4d5874a182ac92d7bd15161da7582fef30871b60afefee476944e32b41c482f71ceb6c476a5fccb2f65d8d382674a94b5abb4127bc4d8361bffbe8358f577875a0e0e8e1a975b00d8c3509a6566a1a2cd32d42a744b6785806566453903ebe420c6ea9a7eb2becc68cee40b81bee5e9957ccb7a3297545811e72b1b4e73b985ff30aff9abfb04c81b4937d8312f856098f15cf81c66ea2c6d94459ce25d4364e7d8c2aeaa6eace5b3054c976a8eb292fde2839503fb4444ba133c58fd1de38a995001af6af42661bcc6f18b1081c6f0d");
let p1 = hex!("ec716ab3b3d9a53a762934e7e3b8c8e2b43e59309bb739f64a92468d3cd0e24a8752e06335caedaa182effe87d4803c073fd8add45955ec14bf2d0ca31840274e8d6b9cd3664422fa1b88e9cb6ebdf83094ff46d9865d0b71fe55702dd9fc67a14c518e9bac7fe9d8ad38dd898058a0ef8dec8366bc0485d5f3cb73858446a2e437c7055114446d78731fc9d0903bd7869d402bc506dfd21d95f1d19b0d59e2b2bf1d64058b0e5241c7bbc05b45eb66b230247ba0d8daa850bae59e62f76e0de632cafcf8ecdccd662ea645597c72b6beb47eb15c3a343be2351c59220d27e81e56f16f1c252a095ef6e7ebdf9fc2a81e387cf17820d78098ec37a2bf8baf523");
let p2 = hex!("c08013615f1cbba17ad6676b2ccee905fe5d21cbf6c03dd760d630afd8759e6df4ba5aec1ed2a9ef69cc4ad78b1c83245a081be45550613e00bfd282e807fb928a92f08b7737003f805ac4e2c4fa725232c038181ae6b257e410873c254ed438e8450374240a84a65cca22f542d8c983473c260a9bf76af96b978de3e7ee6db6654aa95eef8547636b4fc9b034db914ff781b69fbdcf637f9483966cfa5dda9b072b7359c2afcfd497585ddfdfad90ce6502cfbc693c22884e94da1eaf49c92a4ea342f7edd2bd182869107e6bfd0ba6fee89b731cd9f31c8d90b7d04da342ae23bf6dcc49ca829c4e53e70b7e329ceda62986b41e6ab4910068ac66df44c235");

let raw = RsaPrivateKey::from_components(
BigUint::from_bytes_be(&n),
Expand Down

0 comments on commit a3b481d

Please sign in to comment.