Skip to content

Commit

Permalink
Re-add broken test as comment for future examination
Browse files Browse the repository at this point in the history
  • Loading branch information
Firstyear committed Jan 25, 2024
1 parent f86411c commit b13dda1
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/crypto/hs256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl TryFrom<&[u8]> for JwsHs256Signer {
let digest = hash::MessageDigest::sha256();

let kid = hash::hash(digest, buf)
.map(|hashout| hex::encode(hashout))
.map(hex::encode)
.map_err(|_| JwtError::OpenSSLError)?;

let skey = pkey::PKey::hmac(buf).map_err(|e| {
Expand Down
91 changes: 91 additions & 0 deletions src/crypto/ms_oapxbc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,95 @@ mod tests {

assert!(session_key.assert_key(&expected_session_key));
}

/*
#[test]
fn ms_oapxbc_3_2_5_1_3_prt_request_response_1() {
let _ = tracing_subscriber::fmt::try_init();
let rsa_priv_key = Rsa::private_key_from_der(&[
48, 130, 4, 163, 2, 1, 0, 2, 130, 1, 1, 0, 191, 143, 29, 122, 36, 141, 175, 52, 119,
240, 95, 222, 55, 208, 8, 107, 72, 65, 77, 191, 241, 26, 139, 79, 181, 67, 75, 0, 18,
44, 117, 3, 120, 150, 37, 29, 217, 197, 134, 61, 206, 186, 138, 129, 92, 66, 146, 137,
240, 119, 57, 13, 24, 194, 133, 174, 131, 11, 50, 184, 174, 170, 99, 40, 217, 58, 200,
202, 59, 179, 164, 199, 10, 27, 15, 74, 6, 67, 154, 209, 38, 53, 166, 148, 86, 109,
119, 100, 79, 228, 116, 102, 159, 120, 226, 123, 225, 90, 242, 195, 29, 221, 120, 176,
226, 91, 209, 179, 17, 201, 25, 34, 157, 139, 199, 152, 218, 25, 69, 144, 61, 239, 217,
191, 223, 242, 94, 89, 180, 62, 148, 107, 106, 251, 96, 74, 23, 243, 145, 66, 164, 233,
87, 19, 202, 19, 26, 104, 121, 25, 96, 118, 6, 229, 89, 243, 125, 253, 79, 149, 75,
247, 162, 99, 59, 188, 182, 247, 8, 201, 246, 112, 26, 31, 119, 190, 254, 180, 84, 13,
250, 50, 117, 236, 82, 31, 160, 223, 185, 220, 64, 118, 169, 64, 107, 54, 205, 141,
145, 208, 144, 255, 214, 143, 17, 99, 204, 233, 59, 135, 208, 17, 46, 230, 148, 25,
133, 46, 18, 129, 125, 41, 71, 129, 204, 43, 78, 180, 63, 148, 142, 8, 134, 52, 196,
210, 186, 246, 120, 143, 7, 251, 205, 217, 156, 30, 70, 150, 218, 42, 84, 160, 177,
231, 240, 119, 2, 3, 1, 0, 1, 2, 130, 1, 0, 28, 36, 174, 27, 126, 88, 84, 151, 220, 81,
51, 252, 133, 109, 170, 118, 252, 144, 31, 152, 166, 23, 20, 197, 154, 167, 110, 210,
237, 88, 155, 190, 109, 78, 125, 216, 131, 96, 170, 70, 213, 99, 1, 171, 92, 191, 41,
33, 91, 243, 96, 45, 228, 231, 219, 85, 22, 202, 163, 226, 143, 66, 216, 59, 173, 162,
157, 210, 92, 112, 25, 178, 230, 112, 176, 79, 219, 88, 190, 91, 161, 5, 251, 217, 202,
82, 221, 218, 30, 132, 189, 119, 64, 81, 181, 208, 166, 124, 194, 178, 216, 229, 235,
111, 237, 105, 185, 6, 218, 131, 149, 142, 72, 224, 58, 236, 97, 138, 153, 246, 69,
171, 65, 238, 23, 60, 88, 17, 11, 120, 19, 5, 73, 125, 30, 54, 205, 1, 137, 165, 14,
185, 105, 27, 121, 181, 105, 237, 137, 5, 121, 84, 155, 176, 108, 9, 113, 13, 195, 105,
154, 208, 146, 179, 101, 83, 207, 21, 135, 23, 67, 34, 228, 209, 3, 110, 35, 31, 138,
132, 90, 59, 21, 206, 60, 37, 75, 102, 101, 111, 142, 225, 46, 241, 145, 57, 105, 69,
157, 43, 22, 16, 202, 172, 4, 103, 161, 232, 151, 228, 105, 206, 94, 207, 1, 81, 177,
31, 234, 190, 156, 123, 93, 125, 10, 65, 141, 175, 199, 140, 162, 136, 131, 244, 81,
83, 79, 87, 9, 66, 48, 129, 127, 157, 87, 105, 189, 149, 186, 26, 20, 63, 198, 222, 94,
49, 2, 129, 129, 0, 243, 33, 60, 82, 189, 78, 48, 104, 168, 181, 202, 9, 229, 45, 245,
100, 168, 226, 244, 75, 187, 199, 142, 18, 250, 45, 231, 132, 83, 133, 80, 128, 247,
249, 216, 20, 80, 245, 243, 164, 175, 4, 172, 145, 204, 229, 175, 114, 93, 204, 153,
66, 198, 182, 168, 1, 165, 51, 100, 133, 22, 121, 155, 44, 38, 245, 96, 52, 207, 120,
72, 48, 179, 251, 17, 59, 205, 76, 0, 191, 138, 252, 80, 184, 124, 75, 153, 229, 29,
168, 165, 77, 144, 212, 41, 204, 9, 137, 154, 166, 2, 135, 89, 39, 25, 208, 82, 20, 76,
245, 14, 58, 9, 85, 17, 71, 199, 248, 12, 27, 24, 26, 216, 76, 197, 223, 142, 145, 2,
129, 129, 0, 201, 179, 5, 34, 16, 74, 254, 62, 83, 131, 189, 101, 29, 51, 181, 119, 15,
157, 213, 59, 213, 209, 233, 132, 28, 106, 116, 202, 119, 60, 65, 49, 125, 33, 147,
178, 169, 4, 254, 113, 160, 97, 69, 210, 168, 81, 88, 140, 13, 90, 17, 5, 70, 130, 64,
60, 70, 71, 178, 67, 253, 102, 58, 4, 51, 208, 17, 252, 213, 167, 228, 218, 4, 142,
206, 217, 71, 136, 55, 37, 89, 11, 100, 120, 214, 213, 160, 98, 215, 98, 221, 177, 220,
253, 242, 238, 207, 161, 108, 250, 78, 0, 232, 84, 154, 15, 173, 216, 82, 95, 37, 214,
4, 154, 26, 174, 98, 25, 92, 43, 195, 141, 247, 172, 18, 12, 162, 135, 2, 129, 129, 0,
190, 169, 119, 166, 226, 241, 168, 32, 202, 253, 20, 157, 193, 237, 210, 156, 199, 156,
131, 59, 200, 220, 107, 92, 18, 121, 97, 47, 114, 87, 255, 147, 195, 227, 88, 66, 70,
99, 58, 88, 17, 48, 55, 44, 119, 100, 63, 188, 14, 54, 222, 145, 113, 71, 216, 100,
193, 234, 149, 143, 144, 218, 120, 135, 157, 93, 155, 190, 142, 92, 163, 48, 30, 84,
107, 101, 92, 79, 151, 222, 157, 221, 212, 103, 120, 129, 201, 3, 213, 200, 101, 41,
120, 196, 8, 171, 11, 103, 175, 177, 52, 22, 116, 33, 167, 170, 168, 83, 103, 46, 93,
163, 193, 161, 198, 85, 102, 73, 237, 36, 106, 56, 211, 27, 17, 169, 137, 33, 2, 129,
128, 40, 193, 13, 86, 118, 168, 80, 122, 211, 113, 25, 1, 167, 70, 221, 113, 179, 44,
22, 251, 194, 22, 105, 242, 145, 179, 72, 233, 231, 241, 186, 210, 127, 16, 27, 193,
203, 185, 0, 152, 128, 233, 102, 172, 75, 234, 51, 212, 8, 150, 156, 61, 206, 163, 94,
203, 79, 0, 9, 155, 7, 70, 114, 142, 138, 209, 141, 240, 226, 82, 204, 64, 233, 14,
217, 232, 185, 53, 98, 191, 31, 32, 216, 42, 58, 110, 107, 187, 204, 253, 99, 2, 31,
63, 8, 169, 12, 54, 247, 200, 19, 158, 199, 82, 224, 214, 46, 48, 57, 100, 148, 70,
140, 35, 127, 36, 161, 25, 178, 175, 253, 17, 96, 107, 218, 49, 199, 93, 2, 129, 128,
122, 254, 238, 22, 221, 153, 158, 56, 73, 156, 136, 73, 21, 108, 74, 140, 229, 0, 155,
134, 174, 239, 77, 131, 172, 97, 124, 246, 89, 207, 110, 20, 179, 205, 148, 132, 165,
192, 71, 32, 119, 164, 250, 59, 194, 33, 167, 180, 178, 204, 158, 140, 8, 218, 157, 20,
80, 234, 123, 180, 227, 78, 49, 92, 207, 37, 134, 73, 81, 35, 31, 97, 5, 99, 235, 56,
74, 89, 3, 179, 125, 27, 31, 234, 104, 150, 238, 45, 24, 85, 156, 48, 177, 161, 19,
124, 122, 43, 156, 253, 219, 220, 25, 178, 136, 248, 211, 151, 19, 198, 129, 239, 28,
97, 81, 0, 93, 200, 46, 237, 92, 96, 16, 138, 17, 203, 39, 237,
])
.unwrap();
let mut cek = general_purpose::URL_SAFE_NO_PAD
.decode("GBxS4SdM29dvIiVaG8ywUqkcvj-n6sd_ypBlpoAZA3bISTeLSA7o5Alf6XXokdQrzb6FwmJ8Fzkdo9l4Q7Bq6Wg6emFyg52_ME_TejQdX9ComlOxsJYYd_-DbMYtTkivV9kgGEKTBRQA1IAKLkVn2cYrubp0aYtuPxXnXkbNjpuGYDHnjh_CDYaoRjjlbfO3mB3D0B3gcYYWE06dZO6uFjVpyQJuBsA4mydqZ73FtRT14SqMO1Szdt43KZvFl339QPr6mJTt1DtGMj5fNFiufI01GzDTqTvm9oWJk7V-BEX2BdMzjUepi9qce6IkWFDji36-Cl-tkghd6pjzkbTNka_Ue4z0ON2PEisftuarS1td1ACTZI1gfe4d4lW8Gn7eAodkPosE")
.unwrap();
// Test truncating to a 244/256 byte boundary
cek.truncate(256);
let cek = general_purpose::URL_SAFE_NO_PAD
.encode(&cek);
let jwe_str = format!("eyJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiUlNBLU9BRVAifQ.{}.Og3wmuWteE9ImPIP.HA.W5OXFtOnLYvIOQRxwdyb2Q", cek);
let jwec = JweCompact::from_str(jwe_str.as_str()).unwrap();
let _session_key = MsOapxbcSessionKey::complete_rsa_oaep_key_agreement(rsa_priv_key, &jwec)
.expect("Failed to fetch the session key");
}
*/
}

0 comments on commit b13dda1

Please sign in to comment.