From 3cb5005987d5d6bde0d6a9b4f6246bd9bd34bfcb Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Wed, 26 Jul 2023 10:41:03 -0400 Subject: [PATCH 1/2] validation: add CryptoOps trait Signed-off-by: William Woodruff --- .../src/backend.rs | 20 +++++++++++++++++++ .../cryptography-x509-validation/src/lib.rs | 1 + 2 files changed, 21 insertions(+) create mode 100644 src/rust/cryptography-x509-validation/src/backend.rs diff --git a/src/rust/cryptography-x509-validation/src/backend.rs b/src/rust/cryptography-x509-validation/src/backend.rs new file mode 100644 index 000000000000..c22b053e8e4a --- /dev/null +++ b/src/rust/cryptography-x509-validation/src/backend.rs @@ -0,0 +1,20 @@ +// This file is dual licensed under the terms of the Apache License, Version +// 2.0, and the BSD License. See the LICENSE file in the root of this repository +// for complete details. + +//! Behavioral typing for a "backend" that provides cryptographic operations. + +use cryptography_x509::certificate::Certificate; + +pub trait CryptoOps { + /// A public key type for this backend. + type Key; + + /// Extracts the public key from the given `Certificate` in + /// a `Key` format known by the backend. + fn public_key(&self, cert: &Certificate) -> Self::Key; + + /// Verifies the signature on `Certificate` using the given + /// `Key`. + fn is_signed_by(&self, cert: &Certificate, key: Self::Key) -> bool; +} diff --git a/src/rust/cryptography-x509-validation/src/lib.rs b/src/rust/cryptography-x509-validation/src/lib.rs index 764c699e7fa4..5773802a4abf 100644 --- a/src/rust/cryptography-x509-validation/src/lib.rs +++ b/src/rust/cryptography-x509-validation/src/lib.rs @@ -4,4 +4,5 @@ #![forbid(unsafe_code)] +pub mod backend; pub mod types; From 92f44da88e897da360c0e14006662c94243eb7d2 Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Wed, 26 Jul 2023 10:51:58 -0400 Subject: [PATCH 2/2] validation: rename: backend -> ops Signed-off-by: William Woodruff --- src/rust/cryptography-x509-validation/src/lib.rs | 2 +- .../cryptography-x509-validation/src/{backend.rs => ops.rs} | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) rename src/rust/cryptography-x509-validation/src/{backend.rs => ops.rs} (76%) diff --git a/src/rust/cryptography-x509-validation/src/lib.rs b/src/rust/cryptography-x509-validation/src/lib.rs index 5773802a4abf..212642f6d428 100644 --- a/src/rust/cryptography-x509-validation/src/lib.rs +++ b/src/rust/cryptography-x509-validation/src/lib.rs @@ -4,5 +4,5 @@ #![forbid(unsafe_code)] -pub mod backend; +pub mod ops; pub mod types; diff --git a/src/rust/cryptography-x509-validation/src/backend.rs b/src/rust/cryptography-x509-validation/src/ops.rs similarity index 76% rename from src/rust/cryptography-x509-validation/src/backend.rs rename to src/rust/cryptography-x509-validation/src/ops.rs index c22b053e8e4a..6d5b27e0a4ce 100644 --- a/src/rust/cryptography-x509-validation/src/backend.rs +++ b/src/rust/cryptography-x509-validation/src/ops.rs @@ -2,16 +2,14 @@ // 2.0, and the BSD License. See the LICENSE file in the root of this repository // for complete details. -//! Behavioral typing for a "backend" that provides cryptographic operations. - use cryptography_x509::certificate::Certificate; pub trait CryptoOps { - /// A public key type for this backend. + /// A public key type for this cryptographic backend. type Key; /// Extracts the public key from the given `Certificate` in - /// a `Key` format known by the backend. + /// a `Key` format known by the cryptographic backend. fn public_key(&self, cert: &Certificate) -> Self::Key; /// Verifies the signature on `Certificate` using the given