mirror of
https://github.com/trussed-dev/piv-authenticator.git
synced 2026-06-20 04:16:15 -07:00
Fix generation of RSA keys
This commit is contained in:
+7
-1
@@ -23,7 +23,7 @@ hex-literal = "0.3"
|
||||
interchange = "0.2.2"
|
||||
iso7816 = "0.1"
|
||||
serde = { version = "1", default-features = false, features = ["derive"] }
|
||||
trussed = "0.1"
|
||||
trussed = { version = "0.1", features = ["rsa2048", "rsa4096"] }
|
||||
untrusted = "0.9"
|
||||
vpicc = { version = "0.1.0", optional = true }
|
||||
log = "0.4"
|
||||
@@ -63,3 +63,9 @@ log-error = []
|
||||
|
||||
[patch.crates-io]
|
||||
trussed = { git = "https://github.com/Nitrokey/trussed", tag = "v0.1.0-nitrokey-3"}
|
||||
|
||||
[profile.dev.package.rsa]
|
||||
opt-level = 2
|
||||
|
||||
[profile.dev.package.num-bigint-dig]
|
||||
opt-level = 2
|
||||
|
||||
+3
-3
@@ -899,7 +899,7 @@ impl<'a, T: trussed::Client + trussed::client::Ed255> LoadedAuthenticator<'a, T>
|
||||
match parsed_mechanism {
|
||||
AsymmetricAlgorithms::P256 => {
|
||||
let serialized_key = syscall!(self.trussed.serialize_key(
|
||||
trussed::types::Mechanism::P256,
|
||||
parsed_mechanism.key_mechanism(),
|
||||
public_key,
|
||||
trussed::types::KeySerialization::Raw
|
||||
))
|
||||
@@ -916,7 +916,7 @@ impl<'a, T: trussed::Client + trussed::client::Ed255> LoadedAuthenticator<'a, T>
|
||||
reply.expand(&[0x7F, 0x49])?;
|
||||
let offset = reply.len();
|
||||
let serialized_e = syscall!(self.trussed.serialize_key(
|
||||
trussed::types::Mechanism::P256,
|
||||
parsed_mechanism.key_mechanism(),
|
||||
public_key,
|
||||
trussed::types::KeySerialization::RsaE
|
||||
))
|
||||
@@ -926,7 +926,7 @@ impl<'a, T: trussed::Client + trussed::client::Ed255> LoadedAuthenticator<'a, T>
|
||||
reply.expand(&serialized_e)?;
|
||||
|
||||
let serialized_n = syscall!(self.trussed.serialize_key(
|
||||
trussed::types::Mechanism::P256,
|
||||
parsed_mechanism.key_mechanism(),
|
||||
public_key,
|
||||
trussed::types::KeySerialization::RsaN
|
||||
))
|
||||
|
||||
+1
-1
@@ -396,7 +396,7 @@ impl Persistent {
|
||||
client: &mut impl trussed::Client,
|
||||
) -> KeyId {
|
||||
let id = syscall!(client.generate_key(
|
||||
alg.key_mechanism(),
|
||||
dbg!(alg.key_mechanism()),
|
||||
StorageAttributes::default().set_persistence(Location::Internal)
|
||||
))
|
||||
.key;
|
||||
|
||||
+29
-1
@@ -9,7 +9,7 @@ use std::process::Command;
|
||||
|
||||
use card::with_vsc;
|
||||
|
||||
use expectrl::{spawn, Eof, Regex, WaitStatus};
|
||||
use expectrl::{spawn, Eof, WaitStatus};
|
||||
|
||||
#[test]
|
||||
fn list() {
|
||||
@@ -56,3 +56,31 @@ fn admin_card() {
|
||||
assert_eq!(p.wait().unwrap(), WaitStatus::Exited(p.pid(), 0));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn generate_key() {
|
||||
with_vsc(|| {
|
||||
let mut command = Command::new("piv-tool");
|
||||
command
|
||||
.env("PIV_EXT_AUTH_KEY", "tests/default_admin_key")
|
||||
.args(&["-A", "M:9B:03", "-G", "9A:11"]);
|
||||
let mut p = expectrl::session::Session::spawn(command).unwrap();
|
||||
p.check("Using reader with a card: Virtual PCD 00 00")
|
||||
.unwrap();
|
||||
p.check(Eof).unwrap();
|
||||
// Non zero exit code?
|
||||
assert_eq!(p.wait().unwrap(), WaitStatus::Exited(p.pid(), 1));
|
||||
});
|
||||
with_vsc(|| {
|
||||
let mut command = Command::new("piv-tool");
|
||||
command
|
||||
.env("PIV_EXT_AUTH_KEY", "tests/default_admin_key")
|
||||
.args(&["-A", "M:9B:03", "-G", "9A:07"]);
|
||||
let mut p = expectrl::session::Session::spawn(command).unwrap();
|
||||
p.check("Using reader with a card: Virtual PCD 00 00")
|
||||
.unwrap();
|
||||
p.check(Eof).unwrap();
|
||||
// Non zero exit code?
|
||||
assert_eq!(p.wait().unwrap(), WaitStatus::Exited(p.pid(), 1));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user