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

validation: add CryptoOps trait #9297

Merged
merged 2 commits into from
Jul 26, 2023
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
1 change: 1 addition & 0 deletions src/rust/cryptography-x509-validation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

#![forbid(unsafe_code)]

pub mod ops;
pub mod types;
18 changes: 18 additions & 0 deletions src/rust/cryptography-x509-validation/src/ops.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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.

use cryptography_x509::certificate::Certificate;

pub trait CryptoOps {
/// 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 cryptographic 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;
}