Skip to content

Commit 1e24606

Browse files
authored
validation: add CryptoOps trait (#9297)
* validation: add CryptoOps trait Signed-off-by: William Woodruff <william@trailofbits.com> * validation: rename: backend -> ops Signed-off-by: William Woodruff <william@trailofbits.com> --------- Signed-off-by: William Woodruff <william@trailofbits.com>
1 parent 1fac99a commit 1e24606

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/rust/cryptography-x509-validation/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44

55
#![forbid(unsafe_code)]
66

7+
pub mod ops;
78
pub mod types;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This file is dual licensed under the terms of the Apache License, Version
2+
// 2.0, and the BSD License. See the LICENSE file in the root of this repository
3+
// for complete details.
4+
5+
use cryptography_x509::certificate::Certificate;
6+
7+
pub trait CryptoOps {
8+
/// A public key type for this cryptographic backend.
9+
type Key;
10+
11+
/// Extracts the public key from the given `Certificate` in
12+
/// a `Key` format known by the cryptographic backend.
13+
fn public_key(&self, cert: &Certificate) -> Self::Key;
14+
15+
/// Verifies the signature on `Certificate` using the given
16+
/// `Key`.
17+
fn is_signed_by(&self, cert: &Certificate, key: Self::Key) -> bool;
18+
}

0 commit comments

Comments
 (0)