Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace k256 with secp256k1 crate #141

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ getrandom = "0.2.14"
hex = { version = "0.4.3", features = ["std"], default-features = false }
intel-tee-quote-verification-rs = { package = "teepot-tee-quote-verification-rs", path = "crates/teepot-tee-quote-verification-rs", version = "0.2.3-alpha.1" }
intel-tee-quote-verification-sys = { version = "0.2.1" }
k256 = "0.13"
secp256k1 = { version = "0.29", features = ["rand-std"] }
log = "0.4"
num-integer = "0.1.46"
num-traits = "0.2.18"
Expand Down
2 changes: 1 addition & 1 deletion bin/tee-key-preexec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ repository.workspace = true

[dependencies]
anyhow.workspace = true
k256.workspace = true
rand.workspace = true
secp256k1.workspace = true
teepot.workspace = true
tracing.workspace = true
tracing-log.workspace = true
Expand Down
15 changes: 8 additions & 7 deletions bin/tee-key-preexec/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
#![deny(clippy::all)]

use anyhow::{Context, Result};
use k256::ecdsa::SigningKey;
use k256::pkcs8::{EncodePrivateKey, LineEnding};
use secp256k1::{rand, Keypair, PublicKey, Secp256k1, SecretKey};

use std::env;
use std::os::unix::process::CommandExt;
Expand Down Expand Up @@ -38,10 +37,12 @@ fn main_with_error() -> Result<()> {
}

let mut rng = rand::thread_rng();
let signing_key = SigningKey::random(&mut rng);
let verifying_key_bytes = signing_key.verifying_key().to_sec1_bytes();
let signing_key_string = signing_key.to_pkcs8_pem(LineEnding::LF)?;
let tee_type = match get_quote(&verifying_key_bytes) {
let secp = Secp256k1::new();
let keypair = Keypair::new(&secp, &mut rng);
let signing_key = SecretKey::from_keypair(&keypair);
let verifying_key = PublicKey::from_keypair(&keypair);
let verifying_key_bytes = verifying_key.serialize();
let tee_type = match get_quote(verifying_key_bytes.as_ref()) {
Ok(quote) => {
// save quote to file
std::fs::write(TEE_QUOTE_FILE, quote)?;
Expand All @@ -56,7 +57,7 @@ fn main_with_error() -> Result<()> {

let err = Command::new(&args[1])
.args(&args[2..])
.env("TEE_SIGNING_KEY", signing_key_string)
.env("TEE_SIGNING_KEY", signing_key.display_secret().to_string())
.env("TEE_QUOTE_FILE", TEE_QUOTE_FILE)
.env("TEE_TYPE", tee_type)
.exec();
Expand Down
3 changes: 1 addition & 2 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ allow = [
"Unlicense",
"MPL-2.0",
"Unicode-DFS-2016",
# "CC0-1.0", # not yet seen
"BSD-2-Clause",
"BSD-3-Clause",
"OpenSSL",
"Unicode-3.0",
"CC0-1.0",
]
deny = []
allow-osi-fsf-free = "neither"
Expand Down