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

refactor: Remove openssl feature flag #940

Merged
merged 1 commit into from
Feb 24, 2025
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
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ test-wasm:
test-wasm-web:
cd sdk && wasm-pack test --chrome --headless -- --features="serialize_thumbnails"

# WASI testing requires the WASI SDK https://github.com/WebAssembly/wasi-sdk installed in /opt,
# wasmtime, and the target wasm32-wasip2 on the nightly toolchain
# WASI testing requires upstream llvm clang (not XCode), wasmtime, and the target wasm32-wasip2 on the nightly toolchain
test-wasi:
CC=/opt/wasi-sdk/bin/clang CARGO_TARGET_WASM32_WASIP2_RUNNER="wasmtime -S cli -S http --dir ." cargo +nightly test --target wasm32-wasip2 -p c2pa -p c2pa-crypto --all-features
ifeq ($(PLATFORM),mac)
$(eval CC := /opt/homebrew/opt/llvm/bin/clang)
endif
CC=$(CC) CARGO_TARGET_WASM32_WASIP2_RUNNER="wasmtime -S cli -S http --dir ." cargo +nightly test --target wasm32-wasip2 -p c2pa -p c2pa-crypto --all-features
rm -r sdk/Users

# Full local validation, build and test all features including wasm
Expand Down
2 changes: 1 addition & 1 deletion cawg_identity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ v1_api = ["c2pa/v1_api"]
[dependencies]
async-trait = "0.1.78"
base64 = "0.22.1"
c2pa = { path = "../sdk", version = "0.46.0", features = ["openssl"] }
c2pa = { path = "../sdk", version = "0.46.0" }
c2pa-crypto = { path = "../internal/crypto", version = "0.6.2" }
c2pa-status-tracker = { path = "../internal/status-tracker", version = "0.5.0" }
chrono = { version = "0.4.38", features = ["serde"] }
Expand Down
2 changes: 1 addition & 1 deletion make_test_images/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ tempfile = "3.15.0"

[features]
# prevents these features from being always enabled in the workspace
default = ["c2pa/openssl_sign", "c2pa/file_io"]
default = ["c2pa/file_io"]
4 changes: 1 addition & 3 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ rustdoc-args = ["--cfg", "docsrs"]

[features]
add_thumbnails = ["image"]
file_io = ["openssl_sign"]
file_io = []
serialize_thumbnails = []
no_interleaved_io = ["file_io"]
fetch_remote_manifests = ["dep:wasi"]
openssl = []
openssl_sign = ["openssl"]
json_schema = ["dep:schemars", "c2pa-crypto/json_schema"]
pdf = ["dep:lopdf"]
v1_api = []
Expand Down
2 changes: 0 additions & 2 deletions sdk/examples/client/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ use anyhow::Result;
// This example is not designed to work with a wasm build
// so we provide this shell to avoid testing errors

#[cfg(feature = "openssl")]
mod client;
fn main() -> Result<()> {
#[cfg(feature = "openssl")]
client::main()?;
Ok(())
}
14 changes: 7 additions & 7 deletions sdk/examples/data_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@
// Example code (in unit test) for how you might use client DataHash values. This allows clients
// to perform the manifest embedding and optionally the hashing

#[cfg(any(feature = "openssl_sign", feature = "file_io"))]
#[cfg(feature = "file_io")]
use std::{
io::{Cursor, Read, Seek, Write},
path::{Path, PathBuf},
};

#[cfg(any(feature = "openssl_sign", feature = "file_io"))]
#[cfg(feature = "file_io")]
use c2pa::{
assertions::{
c2pa_action, labels::*, Action, Actions, CreativeWork, DataHash, Exif, SchemaDotOrgPerson,
},
create_signer, hash_stream_by_alg, Builder, ClaimGeneratorInfo, HashRange, Ingredient, Reader,
Relationship, Result,
};
#[cfg(any(feature = "openssl_sign", feature = "file_io"))]
#[cfg(feature = "file_io")]
use c2pa_crypto::raw_signature::SigningAlg;

fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
println!("DataHash demo");

#[cfg(all(feature = "openssl_sign", feature = "file_io"))]
#[cfg(feature = "file_io")]
user_data_hash_with_sdk_hashing()?;
println!("Done with SDK hashing1");
#[cfg(all(feature = "openssl_sign", feature = "file_io"))]
#[cfg(feature = "file_io")]
user_data_hash_with_user_hashing()?;
println!("Done with SDK hashing2");
Ok(())
Expand Down Expand Up @@ -86,7 +86,7 @@ fn builder_from_source<S: AsRef<Path>>(source: S) -> Result<Builder> {
Ok(builder)
}

#[cfg(all(feature = "openssl_sign", feature = "file_io"))]
#[cfg(feature = "file_io")]
fn user_data_hash_with_sdk_hashing() -> Result<()> {
// You will often implement your own Signer trait to perform on device signing
let signcert_path = "sdk/tests/fixtures/certs/es256.pub";
Expand Down Expand Up @@ -146,7 +146,7 @@ fn user_data_hash_with_sdk_hashing() -> Result<()> {
Ok(())
}

#[cfg(all(feature = "openssl_sign", feature = "file_io"))]
#[cfg(feature = "file_io")]
fn user_data_hash_with_user_hashing() -> Result<()> {
// You will often implement your own Signer trait to perform on device signing
let signcert_path = "sdk/tests/fixtures/certs/es256.pub";
Expand Down
1 change: 0 additions & 1 deletion sdk/examples/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use anyhow::Result;
use c2pa::Reader;

#[cfg(feature = "openssl")]
fn main() -> Result<()> {
let args: Vec<String> = std::env::args().collect();
if args.len() > 1 {
Expand Down
5 changes: 2 additions & 3 deletions sdk/examples/v2api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ fn main() -> Result<()> {
Ok(())
}

// #[cfg(feature = "openssl")]
// use openssl::{error::ErrorStack, pkey::PKey};
// #[cfg(feature = "openssl")]
// fn ed_sign(data: &[u8], pkey: &[u8]) -> std::result::Result<Vec<u8>, ErrorStack> {
Expand All @@ -171,14 +170,14 @@ fn main() -> Result<()> {

#[cfg(test)]
mod tests {
#[cfg(target_arch = "wasm32")]
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
use wasm_bindgen_test::*;

use super::*;

#[cfg_attr(not(target_arch = "wasm32"), actix::test)]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
#[cfg_attr(not(any(target_arch = "wasm32", feature = "openssl")), ignore)]
#[cfg_attr(target_os = "wasi", wstd::test)]
async fn test_v2_api() -> Result<()> {
main()
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/examples/v2show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
//! Example App that generates a manifest store listing for a given file

use anyhow::Result;
#[cfg(any(not(feature = "openssl"), target_arch = "wasm32"))]
#[cfg(target_arch = "wasm32")]
fn main() -> Result<()> {
Ok(())
}

#[cfg(all(feature = "openssl", not(target_arch = "wasm32")))]
#[cfg(not(target_arch = "wasm32"))]
fn main() -> Result<()> {
use std::io::Read;

Expand Down
1 change: 0 additions & 1 deletion sdk/src/assertions/bmff_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,6 @@ pub mod tests {
//use super::*;
use crate::utils::test::fixture_path;

#[cfg(feature = "openssl")]
#[test]
fn test_fragemented_mp4() {
use crate::{
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/asset_handlers/bmff_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,7 @@ pub mod tests {
io_utils::tempdirectory,
test::{fixture_path, temp_dir_path},
};
#[cfg(all(feature = "openssl", feature = "file_io"))]
#[cfg(all(feature = "v1_api", feature = "file_io"))]
#[test]
fn test_read_mp4() {
use c2pa_status_tracker::DetailedStatusTracker;
Expand Down
18 changes: 5 additions & 13 deletions sdk/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1116,9 +1116,9 @@ mod tests {
use wasm_bindgen_test::*;

use super::*;
#[cfg(any(feature = "openssl_sign", target_arch = "wasm32"))]
use crate::{assertions::BoxHash, asset_handlers::jpeg_io::JpegIO};
use crate::{
assertions::BoxHash,
asset_handlers::jpeg_io::JpegIO,
hash_stream_by_alg,
utils::{test::write_jpeg_placeholder_stream, test_signer::test_signer},
validation_results::ValidationState,
Expand Down Expand Up @@ -1190,7 +1190,7 @@ mod tests {
.to_string()
}

#[cfg(any(feature = "file_io", feature = "openssl_sign"))]
#[cfg(feature = "file_io")]
const TEST_IMAGE_CLEAN: &[u8] = include_bytes!("../tests/fixtures/IMG_0003.jpg");
const TEST_IMAGE: &[u8] = include_bytes!("../tests/fixtures/CA.jpg");
const TEST_THUMBNAIL: &[u8] = include_bytes!("../tests/fixtures/thumbnail.jpg");
Expand Down Expand Up @@ -1290,7 +1290,6 @@ mod tests {
}

#[test]
#[cfg_attr(not(any(target_arch = "wasm32", feature = "openssl_sign")), ignore)]
fn test_builder_sign() {
#[derive(Serialize, Deserialize)]
struct TestAssertion {
Expand Down Expand Up @@ -1459,7 +1458,6 @@ mod tests {
all(target_arch = "wasm32", not(target_os = "wasi")),
wasm_bindgen_test
)]
#[cfg_attr(not(any(target_arch = "wasm32", feature = "openssl_sign")), ignore)]
#[cfg_attr(target_os = "wasi", wstd::test)]
async fn test_builder_remote_sign() {
let format = "image/jpeg";
Expand Down Expand Up @@ -1498,7 +1496,7 @@ mod tests {
}

#[test]
#[cfg(feature = "openssl_sign")]
#[cfg(feature = "file_io")]
fn test_builder_remote_url() {
let mut source = Cursor::new(TEST_IMAGE_CLEAN);
let mut dest = Cursor::new(Vec::new());
Expand Down Expand Up @@ -1531,7 +1529,6 @@ mod tests {
}

#[test]
#[cfg_attr(not(any(target_arch = "wasm32", feature = "openssl_sign")), ignore)]
fn test_builder_data_hashed_embeddable() {
const CLOUD_IMAGE: &[u8] = include_bytes!("../tests/fixtures/cloud.jpg");
let mut input_stream = Cursor::new(CLOUD_IMAGE);
Expand Down Expand Up @@ -1596,10 +1593,7 @@ mod tests {
wasm_bindgen_test
)]
#[cfg_attr(target_os = "wasi", wstd::test)]
#[cfg(any(
target_arch = "wasm32",
all(feature = "openssl_sign", feature = "file_io")
))]
#[cfg(any(target_arch = "wasm32", feature = "file_io"))]
async fn test_builder_box_hashed_embeddable() {
use crate::asset_io::{CAIWriter, HashBlockObjectType};
const BOX_HASH_IMAGE: &[u8] = include_bytes!("../tests/fixtures/boxhash.jpg");
Expand Down Expand Up @@ -1704,7 +1698,6 @@ mod tests {
);
}

#[cfg(feature = "openssl_sign")]
const MANIFEST_JSON: &str = r#"{
"claim_generator": "test",
"claim_generator_info": [
Expand Down Expand Up @@ -1835,7 +1828,6 @@ mod tests {
}"#;

#[test]
#[cfg(feature = "openssl_sign")]
/// tests and illustrates how to add assets to a non-file based manifest by using a stream
fn from_json_with_stream_full_resources() {
use crate::assertions::Relationship;
Expand Down
1 change: 0 additions & 1 deletion sdk/src/claim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2845,7 +2845,6 @@ pub(crate) fn check_ocsp_status(
}
}

#[cfg(feature = "openssl")]
#[cfg(test)]
pub mod tests {
#![allow(clippy::expect_used)]
Expand Down
6 changes: 2 additions & 4 deletions sdk/src/cose_sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,11 @@ mod tests {
use c2pa_crypto::raw_signature::SigningAlg;

use super::sign_claim;
#[cfg(all(any(feature = "openssl_sign", target_os = "wasi"), feature = "file_io"))]
#[cfg(feature = "file_io")]
use crate::utils::test_signer::async_test_signer;
use crate::{claim::Claim, utils::test_signer::test_signer, Result, Signer};

#[test]
#[cfg_attr(not(any(target_arch = "wasm32", feature = "openssl_sign")), ignore)]
fn test_sign_claim() {
let mut claim = Claim::new("extern_sign_test", Some("contentauth"), 1);
claim.build().unwrap();
Expand All @@ -288,7 +287,7 @@ mod tests {
assert_eq!(cose_sign1.len(), box_size);
}

#[cfg(all(any(feature = "openssl_sign", target_os = "wasi"), feature = "file_io"))]
#[cfg(feature = "file_io")]
#[cfg_attr(not(target_arch = "wasm32"), actix::test)]
#[cfg_attr(target_os = "wasi", wstd::test)]
async fn test_sign_claim_async() {
Expand Down Expand Up @@ -357,7 +356,6 @@ mod tests {

let _cose_sign1 = sign_claim(&claim_bytes, &signer, box_size);

#[cfg(any(feature = "openssl", target_os = "wasi"))] // there is no verify on sign when openssl is disabled
assert!(_cose_sign1.is_err());
}
}
2 changes: 0 additions & 2 deletions sdk/src/cose_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ pub(crate) fn get_signing_info(

#[allow(unused_imports)]
#[allow(clippy::unwrap_used)]
#[cfg(feature = "openssl_sign")]
#[cfg(test)]
pub mod tests {
use c2pa_crypto::raw_signature::SigningAlg;
Expand Down Expand Up @@ -214,7 +213,6 @@ pub mod tests {
assert_eq!(signing_time, None);
}
#[test]
#[cfg(feature = "openssl_sign")]
fn test_stapled_ocsp() {
use c2pa_crypto::{
raw_signature::{signer_from_cert_chain_and_private_key, RawSigner, RawSignerError},
Expand Down
Loading
Loading