|
| 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