Skip to content

Commit

Permalink
chore: Move ValidationInfo to c2pa-crypto (#721)
Browse files Browse the repository at this point in the history
* Extract ValidationInfo into c2pa-status-tracker

* Move ValidationInfo into c2pa-crypto

* Format
  • Loading branch information
emensch authored Dec 9, 2024
1 parent f110ea8 commit f2ee9e3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
3 changes: 3 additions & 0 deletions internal/crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ pub use signing_alg::{SigningAlg, UnknownAlgorithmError};

pub mod time_stamp;

mod validation_info;
pub use validation_info::ValidationInfo;

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
pub mod webcrypto;

Expand Down
21 changes: 16 additions & 5 deletions sdk/src/validator.rs → internal/crypto/src/validation_info.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 Adobe. All rights reserved.
// Copyright 2024 Adobe. All rights reserved.
// This file is licensed to you under the Apache License,
// Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
// or the MIT license (http://opensource.org/licenses/MIT),
Expand All @@ -11,17 +11,28 @@
// specific language governing permissions and limitations under
// each license.

use c2pa_crypto::SigningAlg;
//! Signature validation info.
use chrono::{DateTime, Utc};
use x509_parser::num_bigint::BigUint;

use crate::SigningAlg;

/// Describes a signature's validation data and status.
#[derive(Debug, Default)]
pub struct ValidationInfo {
pub alg: Option<SigningAlg>, // validation algorithm
/// Algorithm used to validate the signature
pub alg: Option<SigningAlg>,
/// Date the signature was created
pub date: Option<DateTime<Utc>>,
/// Certificate serial number
pub cert_serial_number: Option<BigUint>,
/// Certificate issuer organization
pub issuer_org: Option<String>,
pub validated: bool, // claim signature is valid
pub cert_chain: Vec<u8>, // certificate chain used to validate signature
/// Signature validity
pub validated: bool,
/// Certificate chain used to validate the signature
pub cert_chain: Vec<u8>,
/// Signature revocation status
pub revocation_status: Option<bool>,
}
6 changes: 2 additions & 4 deletions sdk/src/claim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::path::Path;
use std::{collections::HashMap, fmt};

use async_generic::async_generic;
use c2pa_crypto::base64;
use c2pa_crypto::{base64, ValidationInfo};
use c2pa_status_tracker::{log_item, OneShotStatusTracker, StatusTracker};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -54,9 +54,7 @@ use crate::{
salt::{DefaultSalt, SaltGenerator, NO_SALT},
trust_handler::TrustHandlerConfig,
utils::hash_utils::{hash_by_alg, vec_compare, verify_by_alg},
validation_status,
validator::ValidationInfo,
ClaimGeneratorInfo,
validation_status, ClaimGeneratorInfo,
};

const BUILD_HASH_ALG: &str = "sha256";
Expand Down
3 changes: 1 addition & 2 deletions sdk/src/cose_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use c2pa_crypto::{
p1363::parse_ec_der_sig,
raw_signature::{validator_for_signing_alg, RawSignatureValidator},
time_stamp::TimeStampError,
SigningAlg,
SigningAlg, ValidationInfo,
};
use c2pa_status_tracker::{log_item, validation_codes::*, StatusTracker};
use ciborium::value::Value;
Expand All @@ -47,7 +47,6 @@ use crate::{
error::{Error, Result}, // DON'T MOVE
settings::get_settings_value, // DON'T MOVE
trust_handler::{has_allowed_oid, TrustHandlerConfig}, // Eli to move to c2pa-crypto
validator::ValidationInfo, // Eli to move to c2pa-status-tracker
};

pub(crate) const RSA_OID: Oid<'static> = oid!(1.2.840 .113549 .1 .1 .1);
Expand Down
2 changes: 0 additions & 2 deletions sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,3 @@ pub(crate) mod trust_handler;

pub(crate) mod utils;
pub(crate) use utils::{cbor_types, hash_utils};

pub(crate) mod validator;

0 comments on commit f2ee9e3

Please sign in to comment.