Giter Site home page Giter Site logo

c2pa's People

Contributors

faceless2 avatar

Watchers

 avatar

c2pa's Issues

Thumbnail assertion created incorrectly

Example to reproduce:

C2PAStore c2pa = new C2PAStore();
C2PAManifest manifest = new C2PAManifest("urn:manifestid");
c2pa.getManifests().add(manifest);
C2PAClaim claim = manifest.getClaim();
claim.setFormat("image/jpeg");
claim.setInstanceID("urn:instanceid");
manifest.getAssertions().add(new C2PA_AssertionHashData());
manifest.getAssertions().add(new C2PA_AssertionThumbnail("image/png", null, new ByteArrayInputStream(new byte[0]), true));

KeyStore keystore = KeyStore.getInstance("PKCS12");
keystore.load(new FileInputStream(KEY_STORE), KEY_STORE_PASSWORD);
PrivateKey key = (PrivateKey) keystore.getKey(KEY_ALIAS, KEY_PASSWORD);
List<X509Certificate> certs = new ArrayList<>();
for (Certificate c : keystore.getCertificateChain(KEY_ALIAS)) {
    certs.add((X509Certificate) c);
}
manifest.getSignature().setSigner(key, certs);
Json j = C2PAHelper.readJPEG(new FileInputStream("unsigned.jpg"));
C2PAHelper.writeJPEG(j, c2pa, new FileOutputStream("signed.jpg"));

// Read back the signed file
j = C2PAHelper.readJPEG(new FileInputStream("signed.jpg"));
c2pa = (C2PAStore)new BoxFactory().load(j.bufferValue("c2pa"));
manifest = c2pa.getActiveManifest();
for (C2PA_Assertion assertion : manifest.getAssertions()) {
    System.out.println(assertion);
}

Expected output:

{"type":"jumb","class":"C2PA_AssertionHashData","size":193}
{"type":"jumb","class":"C2PA_AssertionThumbnail","size":100}

Actual output:

{"type":"jumb","class":"C2PA_AssertionHashData","size":193}
{"type":"jumb","class":"C2PA_AssertionUnknown"}

signed.jpg

I think the issue comes from the label set in the constructor of C2PA_AssertionThumbnail:

super(SUBTYPE, (claim ? "c2pa.thumbnail.claim." : "c2pa.thumbnail.ingredient.") + mediaSubtype(mediaType), fileName, data);

If I replace SUBTYPE with (claim ? "c2pa.thumbnail.claim." : "c2pa.thumbnail.ingredient.") + mediaSubtype(mediaType), the code seems to work as expected.
However, I'm not 100% sure that this still follows the C2PA spec.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.