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

Key Standard #986

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a2439bb
feat: key standard.
l-monninger Jan 7, 2025
99875dc
feat: create key.
l-monninger Jan 7, 2025
cb0d91e
fix: update SocketAddr to 0.0.0.0
andygolay Jan 8, 2025
725bf22
Convert DER signature to raw signature for AWS KMS signing (#988)
andygolay Jan 9, 2025
a0dca6a
feat: signing works with HashiCorp Vault with underscore delineator i…
andygolay Jan 9, 2025
eca26ef
feat: health check endpoint
andygolay Jan 10, 2025
9fea297
fix: use alias for aws kms signing
andygolay Jan 13, 2025
0aca5a7
fix: remove need for AWS_KMS_KEY_ID env var
andygolay Jan 13, 2025
8ab44be
feat: add verify endpoint
andygolay Jan 14, 2025
07cc911
feat: public_key/get and public_key/set endpoints with axum::Extensio…
andygolay Jan 14, 2025
0313369
fix: remove unneeded comments
andygolay Jan 14, 2025
80555de
Add public key state to HSM Demo (#1001)
andygolay Jan 15, 2025
7ceab36
fix: remove unneeded comments
andygolay Jan 15, 2025
4ec5f63
fix: remove auto-setting public key, only use set endpoint
andygolay Jan 15, 2025
1a952af
fix: remove faulty check for existing public key
andygolay Jan 15, 2025
a2fd6e2
fix: hashicorp signing and public key retrieval
andygolay Jan 15, 2025
2c49fea
fix: consistent public key retrieval
andygolay Jan 16, 2025
ff49b15
Secure signing: Key rotation with CLI (#1002)
andygolay Jan 21, 2025
a669be2
fix: change VAULT_ADDRESS to VAULT_ADDR
andygolay Jan 21, 2025
9c415ad
fix: injective mapping with different delineators for aws and vault
andygolay Jan 21, 2025
ebde351
test: remove conditional to build release
andygolay Jan 24, 2025
8edaa6b
Use `VAULT_ADDR` environment variable to configure `signing-admin rot…
mzabaluev Jan 29, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/hsm-demo-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
jobs:

hsm-demo-build:
if: github.event.label.name == 'cicd:hsm-demo-containers' || github.ref == 'refs/heads/main'
# if: github.event.label.name == 'cicd:hsm-demo-containers' || github.ref == 'refs/heads/main'
permissions:
contents: read
packages: write
Expand Down
48 changes: 48 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ members = [
"util/signing/integrations/aptos",
"util/signing/providers/aws-kms",
"util/signing/providers/hashicorp-vault",
"util/signing/signing-admin",
"demo/hsm"
]

Expand Down Expand Up @@ -354,4 +355,4 @@ opt-level = 3

[patch.crates-io]
merlin = { git = "https://github.com/aptos-labs/merlin" }
x25519-dalek = { git = "https://github.com/aptos-labs/x25519-dalek", branch = "zeroize_v1" }
x25519-dalek = { git = "https://github.com/aptos-labs/x25519-dalek", branch = "zeroize_v1" }
4 changes: 4 additions & 0 deletions demo/hsm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ dotenv = "0.15"
ed25519 = { workspace = true }
ring-compat = { workspace = true }
k256 = { workspace = true, features = ["ecdsa", "pkcs8"] }
ed25519-dalek = { workspace = true }
google-cloud-kms = { workspace = true }
reqwest = { version = "0.12", features = ["json"] }
axum = "0.6"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
clap = { workspace = true }
movement-signer = { workspace = true }
movement-signer-aws-kms = { workspace = true }
movement-signer-hashicorp-vault = { workspace = true }

[lints]
workspace = true
14 changes: 7 additions & 7 deletions demo/hsm/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use clap::Parser;
#[derive(Parser)]
#[clap(rename_all = "kebab-case")]
pub enum HsmDemo {
#[clap(subcommand)]
Server(server::Server),
#[clap(subcommand)]
Server(server::Server),
}

impl HsmDemo {
pub async fn run(&self) -> Result<(), anyhow::Error> {
match self {
HsmDemo::Server(server) => server.run().await,
}
}
pub async fn run(&self) -> Result<(), anyhow::Error> {
match self {
HsmDemo::Server(server) => server.run().await,
}
}
}
39 changes: 24 additions & 15 deletions demo/hsm/src/cli/server/ed25519/hashi_corp_vault.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
use crate::{cryptography::Ed25519, hsm, server::create_server};
use crate::server::{create_server, AppState};
use axum::Server;
use clap::Parser;
use movement_signer::cryptography::ed25519::Ed25519;
use movement_signer::key::Key;
use movement_signer::key::SignerBuilder;
use movement_signer::Signer;
use movement_signer_hashicorp_vault::hsm::key::Builder;
use std::net::SocketAddr;
use std::sync::Arc;
use tokio::sync::Mutex;

#[derive(Debug, Parser, Clone)]
#[clap(rename_all = "kebab-case", about = "Runs signing app for ed25519 against HashiCorp Vault")]
pub struct HashiCorpVault {}
pub struct HashiCorpVault {
canonical_key: String,
#[arg(long)]
create_key: bool,
}

impl HashiCorpVault {
pub async fn run(&self) -> Result<(), anyhow::Error> {
let hsm = hsm::hashi_corp_vault::HashiCorpVault::<Ed25519>::try_from_env()?
.create_key()
.await?
.fill_with_public_key()
.await?;
pub async fn run(&self) -> Result<(), anyhow::Error> {
let key = Key::try_from_canonical_string(self.canonical_key.as_str())
.map_err(|e| anyhow::anyhow!(e))?;
let builder = Builder::<Ed25519>::new().create_key(self.create_key);
let hsm = Signer::new(builder.build(key).await?);

let server_hsm = Arc::new(Mutex::new(hsm));
let server_hsm = Arc::new(Mutex::new(hsm));
let app_state = Arc::new(AppState::new());

let app = create_server(server_hsm);
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("Server listening on {}", addr);
let app = create_server(server_hsm, app_state);
let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
println!("Server listening on {}", addr);

Server::bind(&addr).serve(app.into_make_service()).await?;
Server::bind(&addr).serve(app.into_make_service()).await?;

Ok(())
}
Ok(())
}
}
43 changes: 27 additions & 16 deletions demo/hsm/src/cli/server/secp256k1/aws_kms.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
use crate::{cryptography::Secp256k1, hsm, server::create_server};
use crate::server::create_server;
use crate::server::AppState;
use axum::Server;
use clap::Parser;
use movement_signer::cryptography::secp256k1::Secp256k1;
use movement_signer::key::Key;
use movement_signer::key::SignerBuilder;
use movement_signer::Signer;
use movement_signer_aws_kms::hsm::key::Builder;
use std::net::SocketAddr;
use std::sync::Arc;
use tokio::sync::Mutex;

#[derive(Debug, Parser, Clone)]
#[clap(rename_all = "kebab-case", about = "Runs signing app for secp256k1 against AWS KMS")]
pub struct AwsKms {}
pub struct AwsKms {
canonical_key: String,
#[arg(long)]
create_key: bool,
}

impl AwsKms {
pub async fn run(&self) -> Result<(), anyhow::Error> {
let hsm = hsm::aws_kms::AwsKms::<Secp256k1>::try_from_env()
.await?
.create_key()
.await?
.fill_with_public_key()
.await?;
let server_hsm = Arc::new(Mutex::new(hsm));
pub async fn run(&self) -> Result<(), anyhow::Error> {
let key = Key::try_from_canonical_string(self.canonical_key.as_str())
.map_err(|e| anyhow::anyhow!(e))?;
let builder = Builder::<Secp256k1>::new().create_key(self.create_key);
let hsm = Signer::new(builder.build(key).await?);

let server_hsm = Arc::new(Mutex::new(hsm));
let app_state = Arc::new(AppState::new());

let app = create_server(server_hsm, app_state);

let app = create_server(server_hsm);
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("Server listening on {}", addr);
let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
println!("Server listening on {}", addr);

Server::bind(&addr).serve(app.into_make_service()).await?;
Server::bind(&addr).serve(app.into_make_service()).await?;

Ok(())
}
Ok(())
}
}
4 changes: 2 additions & 2 deletions demo/hsm/src/cryptography/aws_kms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::cryptography::Secp256k1;
use aws_sdk_kms::types::{KeySpec, KeyUsageType, SigningAlgorithmSpec};

/// Defines the needed methods for providing a definition of cryptography used with AWS KMS
pub trait AwsKmsCryptography {
pub trait AwsKmsCryptographySpec {
/// Returns the [KeySpec] for the desired cryptography
fn key_spec() -> KeySpec;

Expand All @@ -13,7 +13,7 @@ pub trait AwsKmsCryptography {
fn signing_algorithm_spec() -> SigningAlgorithmSpec;
}

impl AwsKmsCryptography for Secp256k1 {
impl AwsKmsCryptographySpec for Secp256k1 {
fn key_spec() -> KeySpec {
KeySpec::EccSecgP256K1
}
Expand Down
4 changes: 2 additions & 2 deletions demo/hsm/src/cryptography/hashicorp_vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use crate::cryptography::Ed25519;
use vaultrs::api::transit::KeyType;

/// Defines the needed methods for providing a definition of cryptography used with HashiCorp Vault
pub trait HashiCorpVaultCryptography {
pub trait HashiCorpVaultCryptographySpec {
/// Returns the [KeyType] for the desired cryptography
fn key_type() -> KeyType;
}

impl HashiCorpVaultCryptography for Ed25519 {
impl HashiCorpVaultCryptographySpec for Ed25519 {
fn key_type() -> KeyType {
KeyType::Ed25519
}
Expand Down
101 changes: 0 additions & 101 deletions demo/hsm/src/hsm/aws_kms.rs

This file was deleted.

Loading