contentauth / c2pa-rs

Rust SDK for the core C2PA (Coalition for Content Provenance and Authenticity) specification
Other
99 stars 42 forks source link

Add canon raw 3 to the list of filetypes in bmff_io.rs #469

Open MTRNord opened 1 month ago

MTRNord commented 1 month ago

Hi :)

I locally out of interested tested the code with cr3 files, and it seems like just adding it to the list works considering there are mostly just canon specific tags in it. Would be nice to add it to the list of filetypes :)

If you need some test file for CI I am happy to provide one of my images at any licence required.

Locally I tried this with appending cr3 to https://github.com/contentauth/c2pa-rs/blob/main/sdk/src/asset_handlers/bmff_io.rs#L68

This with the example spits out:

{
  "active_manifest": "urn:uuid:f704df0d-0b4c-4a55-8bb9-8f733d275bf7",
  "manifests": {
    "urn:uuid:f704df0d-0b4c-4a55-8bb9-8f733d275bf7": {
      "claim_generator": "test_app/0.1 c2pa-rs/0.32.1",
      "title": "test.CR3",
      "format": "application/octet-stream",
      "instance_id": "xmp:iid:c6eb9786-c66c-4d44-a2e4-de88f65c4bf7",
      "ingredients": [
        {
          "title": "IMG_7123.CR3",
          "format": "application/octet-stream",
          "instance_id": "xmp:iid:4a48f08d-79f3-43fc-837b-54dce02cf49e",
          "relationship": "parentOf"
        }
      ],
      "assertions": [
        {
          "label": "c2pa.actions",
          "data": {
            "actions": [
              {
                "action": "c2pa.placed",
                "parameters": {
                  "identifier": "xmp:iid:4a48f08d-79f3-43fc-837b-54dce02cf49e"
                }
              }
            ]
          }
        },
        {
          "label": "stds.schema-org.CreativeWork",
          "data": {
            "@context": "http://schema.org/",
            "@type": "CreativeWork",
            "author": [
              {
                "@type": "Person",
                "name": "me"
              }
            ]
          },
          "kind": "Json"
        },
        {
          "label": "stds.exif",
          "data": {
            "@context": {
              "exif": "http://ns.adobe.com/exif/1.0/"
            },
            "exif:GPSLatitude": "39,21.102N",
            "exif:GPSTimeStamp": "2019-09-22T18:22:57Z",
            "exif:GPSLongitude": "74,26.5737W",
            "exif:GPSAltitudeRef": 0,
            "exif:GPSVersionID": "2.2.0.0",
            "exif:GPSAltitude": "100963/29890"
          },
          "kind": "Json"
        },
        {
          "label": "c2pa.hash.bmff.v2",
          "data": {
            "exclusions": [
              {
                "xpath": "/uuid",
                "length": null,
                "data": [
                  {
                    "offset": 8,
                    "value": [
                      216,
                      254,
                      195,
                      214,
                      27,
                      14,
                      72,
                      60,
                      146,
                      151,
                      88,
                      40,
                      135,
                      126,
                      196,
                      129
                    ]
                  }
                ],
                "subset": null,
                "version": null,
                "flags": null,
                "exact": null
              },
              {
                "xpath": "/ftyp",
                "length": null,
                "data": null,
                "subset": null,
                "version": null,
                "flags": null,
                "exact": null
              },
              {
                "xpath": "/meta/iloc",
                "length": null,
                "data": null,
                "subset": null,
                "version": null,
                "flags": null,
                "exact": null
              },
              {
                "xpath": "/mfra/tfra",
                "length": null,
                "data": null,
                "subset": null,
                "version": null,
                "flags": null,
                "exact": null
              },
              {
                "xpath": "/moov/trak/mdia/minf/stbl/stco",
                "length": null,
                "data": null,
                "subset": [
                  {
                    "offset": 16,
                    "length": 0
                  }
                ],
                "version": null,
                "flags": null,
                "exact": null
              },
              {
                "xpath": "/moov/trak/mdia/minf/stbl/co64",
                "length": null,
                "data": null,
                "subset": [
                  {
                    "offset": 16,
                    "length": 0
                  }
                ],
                "version": null,
                "flags": null,
                "exact": null
              },
              {
                "xpath": "/moof/traf/tfhd",
                "length": null,
                "data": null,
                "subset": [
                  {
                    "offset": 16,
                    "length": 8
                  }
                ],
                "version": null,
                "flags": [
                  1,
                  0,
                  0
                ],
                "exact": null
              },
              {
                "xpath": "/moof/traf/trun",
                "length": null,
                "data": null,
                "subset": [
                  {
                    "offset": 16,
                    "length": 4
                  }
                ],
                "version": null,
                "flags": [
                  1,
                  0,
                  0
                ],
                "exact": null
              }
            ],
            "alg": "sha256",
            "hash": "0TX4dZONswNJhSxhWrrdjhb6SEbQbjDQQYHvjfqO//0=",
            "name": "jumbf manifest"
          }
        }
      ],
      "signature_info": {
        "alg": "Es256",
        "issuer": "C2PA Test Signing Cert",
        "cert_serial_number": "640229841392226413189608867977836244731148734950"
      },
      "label": "urn:uuid:f704df0d-0b4c-4a55-8bb9-8f733d275bf7"
    }
  }
}

manifest_label: urn:uuid:f704df0d-0b4c-4a55-8bb9-8f733d275bf7
title: test.CR3 , format: application/octet-stream, instance_id: xmp:iid:c6eb9786-c66c-4d44-a2e4-de88f65c4bf7
c2pa.actions
c2pa.placed
stds.schema-org.CreativeWork
author = me 
stds.exif
c2pa.hash.bmff.v2
Ingredient title:IMG_7123.CR3

Which to my untrained eye indicates it is working. there is no visual corruption either so its not overwriting image data for it to work either.

mauricefisher64 commented 1 week ago

We will discuss support for this in SDK.