Skip to content

Commit f07fd7f

Browse files
committed
chore: Move c2pa::CoseValidator to c2pa_crypto::RawSignatureValidator
1 parent fffdd64 commit f07fd7f

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

internal/crypto/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ pub mod hash;
2525
pub(crate) mod internal;
2626

2727
pub mod ocsp;
28-
pub mod validation_codes;
28+
29+
mod raw_signature;
30+
pub use raw_signature::validator::{RawSignatureValidationError, RawSignatureValidator};
2931

3032
mod signing_alg;
3133
pub use signing_alg::{SigningAlg, UnknownAlgorithmError};
3234

35+
pub mod validation_codes;
36+
3337
#[cfg(test)]
3438
pub(crate) mod tests;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2024 Adobe. All rights reserved.
2+
// This file is licensed to you under the Apache License,
3+
// Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
4+
// or the MIT license (http://opensource.org/licenses/MIT),
5+
// at your option.
6+
7+
// Unless required by applicable law or agreed to in writing,
8+
// this software is distributed on an "AS IS" BASIS, WITHOUT
9+
// WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
10+
// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
11+
// specific language governing permissions and limitations under
12+
// each license.
13+
14+
pub(crate) mod validator;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2022 Adobe. All rights reserved.
2+
// This file is licensed to you under the Apache License,
3+
// Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
4+
// or the MIT license (http://opensource.org/licenses/MIT),
5+
// at your option.
6+
7+
// Unless required by applicable law or agreed to in writing,
8+
// this software is distributed on an "AS IS" BASIS, WITHOUT
9+
// WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
10+
// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
11+
// specific language governing permissions and limitations under
12+
// each license.
13+
14+
use thiserror::Error;
15+
16+
/// A `RawSignatureValidator` implementation checks a signature encoded using a
17+
/// specific signature algorithm and a private/public key pair.
18+
///
19+
/// IMPORTANT: This signature is typically embedded in a wrapper provided by
20+
/// another signature mechanism. In the C2PA ecosystem, this wrapper is
21+
/// typically COSE, but `RawSignatureValidator` does not implement COSE.
22+
pub trait RawSignatureValidator {
23+
/// Return `true` if the signature `sig` is valid for the raw content `data`
24+
/// and the public key `public_key`.
25+
fn validate(
26+
&self,
27+
sig: &[u8],
28+
data: &[u8],
29+
public_key: &[u8],
30+
) -> Result<(), RawSignatureValidationError>;
31+
}
32+
33+
/// Describes errors that can be identified when validating a raw signature.
34+
#[derive(Debug, Eq, Error, PartialEq)]
35+
pub enum RawSignatureValidationError {}

0 commit comments

Comments
 (0)