tor-llcrypto: Add test case for RsaIdentity formatting

I'm going to change the code that does this, so add a test first
to check the output doesn't change.

At some point we should have more RSA tests.
This commit is contained in:
Ian Jackson 2022-03-02 16:21:29 +00:00
parent f7009e238a
commit 7a4369e240
1 changed files with 19 additions and 0 deletions

View File

@ -37,6 +37,25 @@ fn test_ed25519_identity() {
assert_eq!(ex3.as_bytes(), &example_key[..]);
}
#[test]
fn test_rsa_formatting() {
use ll::pk::rsa::RsaIdentity;
let id = hex::decode("5696ab38cb3852afa476a5c07b2d4788963d5567").unwrap();
let id = RsaIdentity::from_bytes(&id).unwrap();
assert_eq!(
format!("<<{}>>", id),
"<<$5696ab38cb3852afa476a5c07b2d4788963d5567>>"
);
assert_eq!(
format!("{:?}", id),
"RsaIdentity { $5696ab38cb3852afa476a5c07b2d4788963d5567 }"
);
}
// TODO: Proper tests for RSA keys
#[test]
fn batch_verify() {
use ll::pk::ed25519::*;