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

feat: Adds load_settings and load_settings_file functions #74

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Purpose: Generate the scaffolding for the uniffi library.
fn main() {
uniffi::generate_scaffolding("./src/c2pa.udl").unwrap();
let _result = uniffi::generate_scaffolding("./src/c2pa.udl");
}
35 changes: 31 additions & 4 deletions c2pa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,35 @@
# specific language governing permissions and limitations under
# each license.

from .c2pa_api import Reader, Builder, create_signer, create_remote_signer, sign_ps256
from .c2pa import Error, SigningAlg, CallbackSigner, sdk_version, version
from .c2pa.c2pa import _UniffiConverterTypeSigningAlg, _UniffiConverterTypeReader, _UniffiRustBuffer
from .c2pa_api import (
Reader,
Builder,
create_signer,
create_remote_signer,
sign_ps256,
load_settings_file,
)
from .c2pa import Error, SigningAlg, CallbackSigner, sdk_version, version, load_settings
from .c2pa.c2pa import (
_UniffiConverterTypeSigningAlg,
_UniffiConverterTypeReader,
_UniffiRustBuffer,
)

__all__ = ['Reader', 'Builder', 'CallbackSigner', 'create_signer', 'sign_ps256', 'Error', 'SigningAlg', 'sdk_version', 'version', 'create_remote_signer', '_UniffiConverterTypeSigningAlg', '_UniffiRustBuffer', '_UniffiConverterTypeReader']
__all__ = [
"Reader",
"Builder",
"CallbackSigner",
"create_signer",
"sign_ps256",
"Error",
"SigningAlg",
"sdk_version",
"version",
"load_settings",
"load_settings_file",
"create_remote_signer",
"_UniffiConverterTypeSigningAlg",
"_UniffiRustBuffer",
"_UniffiConverterTypeReader",
]
8 changes: 8 additions & 0 deletions c2pa/c2pa_api/c2pa_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,11 @@ def sign_ps256(data: bytes, key: bytes) -> bytes:
hashes.SHA256()
)
return signature

def load_settings_file(path: str, format=None):
with open(path, "r") as file:
if format is None:
# determine the format from the file extension
format = os.path.splitext(path)[1][1:]
settings = file.read()
api.load_settings(settings, format)
2 changes: 2 additions & 0 deletions src/c2pa.udl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
namespace c2pa {
string version();
string sdk_version();
[Throws=Error]
void load_settings([ByRef] string format, [ByRef] string settings);
};

[Error]
Expand Down
15 changes: 14 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use std::env;
use std::sync::RwLock;

pub use c2pa::{Signer, SigningAlg};
pub use c2pa::{Signer, SigningAlg, settings::load_settings_from_str};

/// these all need to be public so that the uniffi macro can see them
mod error;
Expand Down Expand Up @@ -45,6 +45,11 @@ pub fn sdk_version() -> String {
)
}

pub fn load_settings(settings: &str, format: &str) -> Result<()> {
load_settings_from_str(settings, format)?;
Ok(())
}

pub struct Reader {
reader: RwLock<c2pa::Reader>,
}
Expand Down Expand Up @@ -102,6 +107,14 @@ impl Reader {
}
}

// pub fn validation_state(&self) -> Result<ValidationState> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug leftover?

// if let Ok(st) = self.reader.validation_state() {
// Ok(st.validation_state())
// } else {
// Err(Error::RwLock)
// }
// }

pub fn resource_to_stream(&self, uri: &str, stream: &dyn Stream) -> Result<u64> {
if let Ok(reader) = self.reader.try_read() {
let mut stream = StreamAdapter::from(stream);
Expand Down
229 changes: 229 additions & 0 deletions tests/fixtures/settings.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
# This sample c2pa settings file enables a trust list.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should explain why TOML was picked as a format (I remember there were some challenges because of the type of embedded data. We may want to spare the gotcha to others?)

# In practice you should update the trust anchors from a remote source as needed.
# Many other settings are available, see the c2pa documentation for more information.
[verify]
trusted = true

[trust]
trust_config = """
//id-kp-emailProtection
1.3.6.1.5.5.7.3.4
//id-kp-documentSigning
1.3.6.1.5.5.7.3.36
//id-kp-timeStamping
1.3.6.1.5.5.7.3.8
//id-kp-OCSPSigning
1.3.6.1.5.5.7.3.9
// MS C2PA Signing
1.3.6.1.4.1.311.76.59.1.9
"""
trust_anchors = """
-----BEGIN CERTIFICATE-----
MIICEzCCAcWgAwIBAgIUW4fUnS38162x10PCnB8qFsrQuZgwBQYDK2VwMHcxCzAJ
BgNVBAYTAlVTMQswCQYDVQQIDAJDQTESMBAGA1UEBwwJU29tZXdoZXJlMRowGAYD
VQQKDBFDMlBBIFRlc3QgUm9vdCBDQTEZMBcGA1UECwwQRk9SIFRFU1RJTkdfT05M
WTEQMA4GA1UEAwwHUm9vdCBDQTAeFw0yMjA2MTAxODQ2NDFaFw0zMjA2MDcxODQ2
NDFaMHcxCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTESMBAGA1UEBwwJU29tZXdo
ZXJlMRowGAYDVQQKDBFDMlBBIFRlc3QgUm9vdCBDQTEZMBcGA1UECwwQRk9SIFRF
U1RJTkdfT05MWTEQMA4GA1UEAwwHUm9vdCBDQTAqMAUGAytlcAMhAGPUgK9q1H3D
eKMGqLGjTXJSpsrLpe0kpxkaFMe7KUAuo2MwYTAdBgNVHQ4EFgQUXuZWArP1jiRM
fgye6ZqRyGupTowwHwYDVR0jBBgwFoAUXuZWArP1jiRMfgye6ZqRyGupTowwDwYD
VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwBQYDK2VwA0EA8E79g54u2fUy
dfVLPyqKmtjenOUMvVQD7waNbetLY7kvUJZCd5eaDghk30/Q1RaNjiP/2RfA/it8
zGxQnM2hCA==
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIC2jCCAjygAwIBAgIUYm+LFaltpWbS9kED6RRAamOdUHowCgYIKoZIzj0EAwQw
dzELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMRIwEAYDVQQHDAlTb21ld2hlcmUx
GjAYBgNVBAoMEUMyUEEgVGVzdCBSb290IENBMRkwFwYDVQQLDBBGT1IgVEVTVElO
R19PTkxZMRAwDgYDVQQDDAdSb290IENBMB4XDTIyMDYxMDE4NDY0MFoXDTMyMDYw
NzE4NDY0MFowdzELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMRIwEAYDVQQHDAlT
b21ld2hlcmUxGjAYBgNVBAoMEUMyUEEgVGVzdCBSb290IENBMRkwFwYDVQQLDBBG
T1IgVEVTVElOR19PTkxZMRAwDgYDVQQDDAdSb290IENBMIGbMBAGByqGSM49AgEG
BSuBBAAjA4GGAAQBaifSYJBkf5fgH3FWPxRdV84qwIsLd7RcIDcRJrRkan0xUYP5
zco7R4fFGaQ9YJB8dauyqiNg00LVuPajvKmhgEMAT4eSfEhYC25F2ggXQlBIK3Q7
mkXwJTIJSObnbw4S9Jy3W6OVKq351VpgWUcmhvGRRejW7S/D8L2tzqRW7JPI2uSj
YzBhMB0GA1UdDgQWBBS6OykommTmfYoLJuPN4OU83wjPqjAfBgNVHSMEGDAWgBS6
OykommTmfYoLJuPN4OU83wjPqjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQE
AwIBhjAKBggqhkjOPQQDBAOBiwAwgYcCQV4B6uKKoCWecEDlzj2xQLFPmnBQIOzD
nyiSEcYyrCKwMV+HYS39oM+T53NvukLKUTznHwdWc9++HNaqc+IjsDl6AkIB2lXd
5+s3xf0ioU91GJ4E13o5rpAULDxVSrN34A7BlsaXYQLnSkLMqva6E7nq2JBYjkqf
iwNQm1DDcQPtPTnddOs=
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIICkTCCAhagAwIBAg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ZZ3gdFtDtVjShcwdbqHZdSNU2lNbVCiycjLs/5EMRO
WfAxNZaKUreKGfOZkvQNqBhuebF3AfgmP6iP1qtO8aSilC1/43DjVRx3SZ1eecO6
n0VGjgcCAwEAAaNjMGEwHQYDVR0OBBYEFBTOcmBU5xp7Jfn4Nzyw+kIc73yHMB8G
A1UdIwQYMBaAFBTOcmBU5xp7Jfn4Nzyw+kIc73yHMA8GA1UdEwEB/wQFMAMBAf8w
DgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQCLexj0luEpQh/LEB14
ARG/yQ8iqW2FMonQsobrDQSI4BhrQ4ak5I892MQX9xIoUpRAVp8GkJ/eXM6ChmXa
wMJSkfrPGIvES4TY2CtmXDNo0UmHD1GDfHKQ06FJtRJWpn9upT/9qTclTNtvwxQ8
bKl/y7lrFsn+fQsKL2i5uoQ9nGpXG7WPirJEt9jcld2yylWSStTS4MXJIZSlALIA
mBTkbzEpzBOLHRRezdfoV4hyL/tWyiXa799436kO48KtwEzvYzC5cZ4bqvM5BXQf
6aiIYZT7VypFwJQtpTgnfrsjr2Y8q/+N7FoMpLfFO4eeqtwWPiP/47/lb9np/WQq
iO/yyIwYVwiqVG0AyzA5Z4pdke1t93y3UuhXgxevJ7GqGXuLCM0iMqFrAkPlLJzI
84THLJzFy+wEKH+/L1Zi94cHNj3WvablAMG5v/Kfr6k+KueNQzrY4jZrQPUEdxjv
xk/1hyZg+khAPVKRxhWeIr6/KIuQYu6kJeTqmXKafx5oHAS6OqcK7G1KbEa1bWMV
K0+GGwenJOzSTKWKtLO/6goBItGnhyQJCjwiBKOvcW5yfEVjLT+fJ7dkvlSzFMaM
OZIbev39n3rQTWb4ORq1HIX2JwNsEQX+gBv6aGjMT2a88QFS0TsAA5LtFl8xeVgt
xPd7wFhjRZHfuWb2cs63xjAGjQ==
-----END CERTIFICATE-----
"""
8 changes: 7 additions & 1 deletion tests/test_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import unittest
from unittest.mock import mock_open, patch

from c2pa import Builder, Error, Reader, SigningAlg, create_signer, sdk_version, sign_ps256
from c2pa import Builder, Error, Reader, SigningAlg, create_signer, sdk_version, sign_ps256, load_settings_file

PROJECT_PATH = os.getcwd()

Expand Down Expand Up @@ -51,6 +51,12 @@ def test_reader_bad_format(self):
with open(testPath, "rb") as file:
reader = Reader("badFormat", file)

def test_settings_trust(self):
load_settings_file("tests/fixtures/settings.toml")
with open(testPath, "rb") as file:
reader = Reader("image/jpeg",file)
json = reader.json()
self.assertIn("C.jpg", json)

class TestBuilder(unittest.TestCase):
# Define a manifest as a dictionary
Expand Down
Loading