c2pa-python 0.2.2__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/Cargo.lock +64 -236
  2. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/Cargo.toml +3 -2
  3. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/PKG-INFO +52 -29
  4. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/README.md +50 -27
  5. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/pyproject.toml +3 -0
  6. c2pa_python-0.3.0/src/c2pa.udl +39 -0
  7. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/src/lib.rs +3 -12
  8. c2pa_python-0.3.0/tests/example.py +34 -0
  9. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/tests/test_c2pa.py +19 -17
  10. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/tests/training.py +3 -3
  11. c2pa_python-0.2.2/src/c2pa.udl +0 -25
  12. c2pa_python-0.2.2/src/error.rs +0 -42
  13. c2pa_python-0.2.2/src/json_api.rs +0 -107
  14. c2pa_python-0.2.2/src/signer_info.rs +0 -58
  15. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/.github/workflows/build.yml +0 -0
  16. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/.gitignore +0 -0
  17. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/CODE_OF_CONDUCT.md +0 -0
  18. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/CONTRIBUTING.md +0 -0
  19. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/LICENSE-APACHE +0 -0
  20. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/LICENSE-MIT +0 -0
  21. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/build.rs +0 -0
  22. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/tests/fixtures/A.jpg +0 -0
  23. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/tests/fixtures/C.jpg +0 -0
  24. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/tests/fixtures/es256_certs.pem +0 -0
  25. {c2pa_python-0.2.2 → c2pa_python-0.3.0}/tests/fixtures/es256_private.key +0 -0
@@ -41,12 +41,6 @@ version = "0.5.2"
41
41
  source = "registry+https://github.com/rust-lang/crates.io-index"
42
42
  checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
43
43
 
44
- [[package]]
45
- name = "arrayvec"
46
- version = "0.7.4"
47
- source = "registry+https://github.com/rust-lang/crates.io-index"
48
- checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
49
-
50
44
  [[package]]
51
45
  name = "askama"
52
46
  version = "0.12.0"
@@ -118,6 +112,17 @@ dependencies = [
118
112
  "syn 1.0.109",
119
113
  ]
120
114
 
115
+ [[package]]
116
+ name = "async-generic"
117
+ version = "0.1.2"
118
+ source = "registry+https://github.com/rust-lang/crates.io-index"
119
+ checksum = "86bc01d15ca67ec7653924057aa97c30de62d06a24e6834387eba6c72c8318e7"
120
+ dependencies = [
121
+ "proc-macro2",
122
+ "quote",
123
+ "syn 2.0.37",
124
+ ]
125
+
121
126
  [[package]]
122
127
  name = "async-trait"
123
128
  version = "0.1.73"
@@ -193,12 +198,6 @@ dependencies = [
193
198
  "serde",
194
199
  ]
195
200
 
196
- [[package]]
197
- name = "bit_field"
198
- version = "0.10.2"
199
- source = "registry+https://github.com/rust-lang/crates.io-index"
200
- checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
201
-
202
201
  [[package]]
203
202
  name = "bitflags"
204
203
  version = "1.3.2"
@@ -218,8 +217,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
218
217
  checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587"
219
218
  dependencies = [
220
219
  "arrayref",
221
- "arrayvec 0.5.2",
222
- "constant_time_eq 0.1.5",
220
+ "arrayvec",
221
+ "constant_time_eq",
223
222
  ]
224
223
 
225
224
  [[package]]
@@ -229,21 +228,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
229
228
  checksum = "9e461a7034e85b211a4acb57ee2e6730b32912b06c08cc242243c39fc21ae6a2"
230
229
  dependencies = [
231
230
  "arrayref",
232
- "arrayvec 0.5.2",
233
- "constant_time_eq 0.1.5",
234
- ]
235
-
236
- [[package]]
237
- name = "blake3"
238
- version = "1.5.0"
239
- source = "registry+https://github.com/rust-lang/crates.io-index"
240
- checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87"
241
- dependencies = [
242
- "arrayref",
243
- "arrayvec 0.7.4",
244
- "cc",
245
- "cfg-if",
246
- "constant_time_eq 0.3.0",
231
+ "arrayvec",
232
+ "constant_time_eq",
247
233
  ]
248
234
 
249
235
  [[package]]
@@ -306,16 +292,16 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
306
292
 
307
293
  [[package]]
308
294
  name = "c2pa"
309
- version = "0.26.0"
295
+ version = "0.28.3"
310
296
  source = "registry+https://github.com/rust-lang/crates.io-index"
311
- checksum = "7aa352b27c99f142a8fb16466b36c7d5db933ba11c0898bfce1a622a97bf0437"
297
+ checksum = "cf260678ddf02ac49b8375a1b22192cc375a05ce9ce700f473acc86945f113e7"
312
298
  dependencies = [
313
299
  "asn1-rs",
300
+ "async-generic",
314
301
  "async-trait",
315
302
  "atree",
316
303
  "base64 0.21.4",
317
304
  "bcder",
318
- "blake3",
319
305
  "byteorder",
320
306
  "byteordered",
321
307
  "bytes",
@@ -327,11 +313,12 @@ dependencies = [
327
313
  "extfmt",
328
314
  "fast-xml",
329
315
  "getrandom",
330
- "half 2.2.1",
331
316
  "hex",
317
+ "id3",
332
318
  "image",
333
319
  "img-parts",
334
320
  "instant",
321
+ "jfifdump",
335
322
  "js-sys",
336
323
  "lazy_static",
337
324
  "log",
@@ -370,14 +357,26 @@ dependencies = [
370
357
  ]
371
358
 
372
359
  [[package]]
373
- name = "c2pa-python"
374
- version = "0.2.2"
360
+ name = "c2pa-c"
361
+ version = "0.1.0"
362
+ source = "git+https://github.com/contentauth/c2pa-c.git?branch=gpeacock/rlib#c2f116800bcde9900f8c02ca09bdf65a31191d1a"
375
363
  dependencies = [
376
364
  "c2pa",
377
365
  "serde",
378
366
  "serde_derive",
379
367
  "serde_json",
380
368
  "thiserror",
369
+ ]
370
+
371
+ [[package]]
372
+ name = "c2pa-python"
373
+ version = "0.3.0"
374
+ dependencies = [
375
+ "c2pa-c",
376
+ "serde",
377
+ "serde_derive",
378
+ "serde_json",
379
+ "thiserror",
381
380
  "uniffi",
382
381
  ]
383
382
 
@@ -467,7 +466,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
467
466
  checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b"
468
467
  dependencies = [
469
468
  "ciborium-io",
470
- "half 1.8.2",
469
+ "half",
471
470
  ]
472
471
 
473
472
  [[package]]
@@ -505,12 +504,6 @@ version = "0.1.5"
505
504
  source = "registry+https://github.com/rust-lang/crates.io-index"
506
505
  checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
507
506
 
508
- [[package]]
509
- name = "constant_time_eq"
510
- version = "0.3.0"
511
- source = "registry+https://github.com/rust-lang/crates.io-index"
512
- checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2"
513
-
514
507
  [[package]]
515
508
  name = "conv"
516
509
  version = "0.3.3"
@@ -554,45 +547,6 @@ dependencies = [
554
547
  "cfg-if",
555
548
  ]
556
549
 
557
- [[package]]
558
- name = "crossbeam-deque"
559
- version = "0.8.3"
560
- source = "registry+https://github.com/rust-lang/crates.io-index"
561
- checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
562
- dependencies = [
563
- "cfg-if",
564
- "crossbeam-epoch",
565
- "crossbeam-utils",
566
- ]
567
-
568
- [[package]]
569
- name = "crossbeam-epoch"
570
- version = "0.9.15"
571
- source = "registry+https://github.com/rust-lang/crates.io-index"
572
- checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
573
- dependencies = [
574
- "autocfg",
575
- "cfg-if",
576
- "crossbeam-utils",
577
- "memoffset",
578
- "scopeguard",
579
- ]
580
-
581
- [[package]]
582
- name = "crossbeam-utils"
583
- version = "0.8.16"
584
- source = "registry+https://github.com/rust-lang/crates.io-index"
585
- checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
586
- dependencies = [
587
- "cfg-if",
588
- ]
589
-
590
- [[package]]
591
- name = "crunchy"
592
- version = "0.2.2"
593
- source = "registry+https://github.com/rust-lang/crates.io-index"
594
- checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
595
-
596
550
  [[package]]
597
551
  name = "crypto-bigint"
598
552
  version = "0.3.2"
@@ -725,12 +679,6 @@ dependencies = [
725
679
  "syn 2.0.37",
726
680
  ]
727
681
 
728
- [[package]]
729
- name = "either"
730
- version = "1.9.0"
731
- source = "registry+https://github.com/rust-lang/crates.io-index"
732
- checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
733
-
734
682
  [[package]]
735
683
  name = "errno"
736
684
  version = "0.3.3"
@@ -752,22 +700,6 @@ dependencies = [
752
700
  "libc",
753
701
  ]
754
702
 
755
- [[package]]
756
- name = "exr"
757
- version = "1.71.0"
758
- source = "registry+https://github.com/rust-lang/crates.io-index"
759
- checksum = "832a761f35ab3e6664babfbdc6cef35a4860e816ec3916dcfd0882954e98a8a8"
760
- dependencies = [
761
- "bit_field",
762
- "flume",
763
- "half 2.2.1",
764
- "lebe",
765
- "miniz_oxide 0.7.1",
766
- "rayon-core",
767
- "smallvec",
768
- "zune-inflate",
769
- ]
770
-
771
703
  [[package]]
772
704
  name = "extfmt"
773
705
  version = "0.1.1"
@@ -808,15 +740,6 @@ dependencies = [
808
740
  "miniz_oxide 0.7.1",
809
741
  ]
810
742
 
811
- [[package]]
812
- name = "flume"
813
- version = "0.11.0"
814
- source = "registry+https://github.com/rust-lang/crates.io-index"
815
- checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181"
816
- dependencies = [
817
- "spin 0.9.8",
818
- ]
819
-
820
743
  [[package]]
821
744
  name = "foreign-types"
822
745
  version = "0.3.2"
@@ -870,16 +793,6 @@ dependencies = [
870
793
  "wasm-bindgen",
871
794
  ]
872
795
 
873
- [[package]]
874
- name = "gif"
875
- version = "0.12.0"
876
- source = "registry+https://github.com/rust-lang/crates.io-index"
877
- checksum = "80792593675e051cf94a4b111980da2ba60d4a83e43e0048c5693baab3977045"
878
- dependencies = [
879
- "color_quant",
880
- "weezl",
881
- ]
882
-
883
796
  [[package]]
884
797
  name = "glob"
885
798
  version = "0.3.1"
@@ -903,15 +816,6 @@ version = "1.8.2"
903
816
  source = "registry+https://github.com/rust-lang/crates.io-index"
904
817
  checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
905
818
 
906
- [[package]]
907
- name = "half"
908
- version = "2.2.1"
909
- source = "registry+https://github.com/rust-lang/crates.io-index"
910
- checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0"
911
- dependencies = [
912
- "crunchy",
913
- ]
914
-
915
819
  [[package]]
916
820
  name = "heck"
917
821
  version = "0.4.1"
@@ -947,6 +851,17 @@ dependencies = [
947
851
  "cc",
948
852
  ]
949
853
 
854
+ [[package]]
855
+ name = "id3"
856
+ version = "1.10.0"
857
+ source = "registry+https://github.com/rust-lang/crates.io-index"
858
+ checksum = "bf8550abe8a02c044e8f4162c8ddb4020fc65b5e7771ad9b80c25e13ed4536b6"
859
+ dependencies = [
860
+ "bitflags 2.4.0",
861
+ "byteorder",
862
+ "flate2",
863
+ ]
864
+
950
865
  [[package]]
951
866
  name = "idna"
952
867
  version = "0.4.0"
@@ -966,14 +881,10 @@ dependencies = [
966
881
  "bytemuck",
967
882
  "byteorder",
968
883
  "color_quant",
969
- "exr",
970
- "gif",
971
884
  "jpeg-decoder",
972
885
  "num-rational",
973
886
  "num-traits",
974
887
  "png",
975
- "qoi",
976
- "tiff",
977
888
  ]
978
889
 
979
890
  [[package]]
@@ -1005,14 +916,20 @@ version = "1.0.9"
1005
916
  source = "registry+https://github.com/rust-lang/crates.io-index"
1006
917
  checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
1007
918
 
919
+ [[package]]
920
+ name = "jfifdump"
921
+ version = "0.4.0"
922
+ source = "registry+https://github.com/rust-lang/crates.io-index"
923
+ checksum = "2b56eea9f2724de66d5f44cbc4b45e716a32c83a581d163cee2b767ddc220426"
924
+ dependencies = [
925
+ "json",
926
+ ]
927
+
1008
928
  [[package]]
1009
929
  name = "jpeg-decoder"
1010
930
  version = "0.3.0"
1011
931
  source = "registry+https://github.com/rust-lang/crates.io-index"
1012
932
  checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e"
1013
- dependencies = [
1014
- "rayon",
1015
- ]
1016
933
 
1017
934
  [[package]]
1018
935
  name = "js-sys"
@@ -1023,6 +940,12 @@ dependencies = [
1023
940
  "wasm-bindgen",
1024
941
  ]
1025
942
 
943
+ [[package]]
944
+ name = "json"
945
+ version = "0.12.4"
946
+ source = "registry+https://github.com/rust-lang/crates.io-index"
947
+ checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd"
948
+
1026
949
  [[package]]
1027
950
  name = "keccak"
1028
951
  version = "0.1.4"
@@ -1038,15 +961,9 @@ version = "1.4.0"
1038
961
  source = "registry+https://github.com/rust-lang/crates.io-index"
1039
962
  checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
1040
963
  dependencies = [
1041
- "spin 0.5.2",
964
+ "spin",
1042
965
  ]
1043
966
 
1044
- [[package]]
1045
- name = "lebe"
1046
- version = "0.5.2"
1047
- source = "registry+https://github.com/rust-lang/crates.io-index"
1048
- checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
1049
-
1050
967
  [[package]]
1051
968
  name = "libc"
1052
969
  version = "0.2.148"
@@ -1065,16 +982,6 @@ version = "0.4.7"
1065
982
  source = "registry+https://github.com/rust-lang/crates.io-index"
1066
983
  checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128"
1067
984
 
1068
- [[package]]
1069
- name = "lock_api"
1070
- version = "0.4.10"
1071
- source = "registry+https://github.com/rust-lang/crates.io-index"
1072
- checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16"
1073
- dependencies = [
1074
- "autocfg",
1075
- "scopeguard",
1076
- ]
1077
-
1078
985
  [[package]]
1079
986
  name = "log"
1080
987
  version = "0.4.20"
@@ -1087,15 +994,6 @@ version = "2.6.3"
1087
994
  source = "registry+https://github.com/rust-lang/crates.io-index"
1088
995
  checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
1089
996
 
1090
- [[package]]
1091
- name = "memoffset"
1092
- version = "0.9.0"
1093
- source = "registry+https://github.com/rust-lang/crates.io-index"
1094
- checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
1095
- dependencies = [
1096
- "autocfg",
1097
- ]
1098
-
1099
997
  [[package]]
1100
998
  name = "mime"
1101
999
  version = "0.3.17"
@@ -1446,15 +1344,6 @@ dependencies = [
1446
1344
  "unicode-ident",
1447
1345
  ]
1448
1346
 
1449
- [[package]]
1450
- name = "qoi"
1451
- version = "0.4.1"
1452
- source = "registry+https://github.com/rust-lang/crates.io-index"
1453
- checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001"
1454
- dependencies = [
1455
- "bytemuck",
1456
- ]
1457
-
1458
1347
  [[package]]
1459
1348
  name = "quote"
1460
1349
  version = "1.0.33"
@@ -1504,26 +1393,6 @@ dependencies = [
1504
1393
  "smallvec",
1505
1394
  ]
1506
1395
 
1507
- [[package]]
1508
- name = "rayon"
1509
- version = "1.8.0"
1510
- source = "registry+https://github.com/rust-lang/crates.io-index"
1511
- checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
1512
- dependencies = [
1513
- "either",
1514
- "rayon-core",
1515
- ]
1516
-
1517
- [[package]]
1518
- name = "rayon-core"
1519
- version = "1.12.0"
1520
- source = "registry+https://github.com/rust-lang/crates.io-index"
1521
- checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
1522
- dependencies = [
1523
- "crossbeam-deque",
1524
- "crossbeam-utils",
1525
- ]
1526
-
1527
1396
  [[package]]
1528
1397
  name = "redox_syscall"
1529
1398
  version = "0.3.5"
@@ -1548,7 +1417,7 @@ dependencies = [
1548
1417
  "cc",
1549
1418
  "libc",
1550
1419
  "once_cell",
1551
- "spin 0.5.2",
1420
+ "spin",
1552
1421
  "untrusted",
1553
1422
  "web-sys",
1554
1423
  "winapi",
@@ -1634,12 +1503,6 @@ version = "1.0.15"
1634
1503
  source = "registry+https://github.com/rust-lang/crates.io-index"
1635
1504
  checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
1636
1505
 
1637
- [[package]]
1638
- name = "scopeguard"
1639
- version = "1.2.0"
1640
- source = "registry+https://github.com/rust-lang/crates.io-index"
1641
- checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
1642
-
1643
1506
  [[package]]
1644
1507
  name = "scroll"
1645
1508
  version = "0.11.0"
@@ -1723,7 +1586,7 @@ version = "0.11.2"
1723
1586
  source = "registry+https://github.com/rust-lang/crates.io-index"
1724
1587
  checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5"
1725
1588
  dependencies = [
1726
- "half 1.8.2",
1589
+ "half",
1727
1590
  "serde",
1728
1591
  ]
1729
1592
 
@@ -1828,15 +1691,6 @@ version = "0.5.2"
1828
1691
  source = "registry+https://github.com/rust-lang/crates.io-index"
1829
1692
  checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
1830
1693
 
1831
- [[package]]
1832
- name = "spin"
1833
- version = "0.9.8"
1834
- source = "registry+https://github.com/rust-lang/crates.io-index"
1835
- checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
1836
- dependencies = [
1837
- "lock_api",
1838
- ]
1839
-
1840
1694
  [[package]]
1841
1695
  name = "spki"
1842
1696
  version = "0.5.4"
@@ -1945,17 +1799,6 @@ dependencies = [
1945
1799
  "syn 2.0.37",
1946
1800
  ]
1947
1801
 
1948
- [[package]]
1949
- name = "tiff"
1950
- version = "0.9.0"
1951
- source = "registry+https://github.com/rust-lang/crates.io-index"
1952
- checksum = "6d172b0f4d3fba17ba89811858b9d3d97f928aece846475bbda076ca46736211"
1953
- dependencies = [
1954
- "flate2",
1955
- "jpeg-decoder",
1956
- "weezl",
1957
- ]
1958
-
1959
1802
  [[package]]
1960
1803
  name = "time"
1961
1804
  version = "0.3.29"
@@ -2354,12 +2197,6 @@ dependencies = [
2354
2197
  "nom",
2355
2198
  ]
2356
2199
 
2357
- [[package]]
2358
- name = "weezl"
2359
- version = "0.1.7"
2360
- source = "registry+https://github.com/rust-lang/crates.io-index"
2361
- checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"
2362
-
2363
2200
  [[package]]
2364
2201
  name = "winapi"
2365
2202
  version = "0.3.9"
@@ -2497,12 +2334,3 @@ name = "zeroize"
2497
2334
  version = "1.6.0"
2498
2335
  source = "registry+https://github.com/rust-lang/crates.io-index"
2499
2336
  checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9"
2500
-
2501
- [[package]]
2502
- name = "zune-inflate"
2503
- version = "0.2.54"
2504
- source = "registry+https://github.com/rust-lang/crates.io-index"
2505
- checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02"
2506
- dependencies = [
2507
- "simd-adler32",
2508
- ]
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "c2pa-python"
3
- version = "0.2.2"
3
+ version = "0.3.0"
4
4
  edition = "2021"
5
5
  authors = ["Gavin Peacock <gpeacock@adobe.com"]
6
6
 
@@ -10,7 +10,8 @@ name = "c2pa_python"
10
10
  crate-type = ["cdylib"]
11
11
 
12
12
  [dependencies]
13
- c2pa = {version="0.26.0", features = ["file_io", "add_thumbnails", "fetch_remote_manifests"]}
13
+ c2pa-c = { git = "https://github.com/contentauth/c2pa-c.git", branch = "gpeacock/rlib"}
14
+ #c2pa = {version="0.26.0", features = ["file_io", "add_thumbnails", "fetch_remote_manifests"]}
14
15
  serde = { version = "1.0", features = ["derive"] }
15
16
  serde_derive = "1.0"
16
17
  serde_json = "1.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: c2pa-python
3
- Version: 0.2.2
3
+ Version: 0.3.0
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Programming Language :: Rust
6
6
  Classifier: Programming Language :: Python :: Implementation :: CPython
@@ -12,7 +12,7 @@ License-File: LICENSE-APACHE
12
12
  Summary: Python bindings for the C2PA Content Authenticity Initiative (CAI) library
13
13
  Keywords: C2PA,CAI,content credentials,metadata,provenance
14
14
  Author: Gavin Peacock <gpeacock@adobe.com
15
- Author-email: Gavin Peacock <gpeacock@adobe.com
15
+ Author-email: Gavin Peacock <gpeacock@adobe.com>
16
16
  Maintainer-email: Gavin Peacock <gpeacock@adobe.com>
17
17
  Requires-Python: >=3.7
18
18
  Description-Content-Type: text/markdown
@@ -25,6 +25,8 @@ Python bindings for the C2PA Content Authenticity Initiative (CAI) library.
25
25
 
26
26
  This library enables you to read and validate C2PA data in supported media files and add signed manifests to supported media files.
27
27
 
28
+ **WARNING**: This is an early prerelease version of this library. There may be bugs and unimplemented features, and the API is subject to change.
29
+
28
30
  ## Installation
29
31
 
30
32
  Install from PyPI by entering this command:
@@ -45,10 +47,10 @@ import c2pa_python as c2pa
45
47
 
46
48
  ### Read and validate C2PA data in a file
47
49
 
48
- Use the `verify_from_file_json` function to read C2PA data from the specified file:
50
+ Use the `read_file` function to read C2PA data from the specified file:
49
51
 
50
52
  ```py
51
- json_store = c2pa.verify_from_file_json("path/to/media_file.jpg", "path/to/data_dir")
53
+ json_store = c2pa.read_file("path/to/media_file.jpg", "path/to/data_dir")
52
54
  ```
53
55
 
54
56
  This function examines the specified media file for C2PA data and generates a JSON report of any data it finds. If there are validation errors, the report includes a `validation_status` field. For a summary of supported media types, see [Supported file formats](#supported-file-formats).
@@ -59,6 +61,25 @@ If the optional `data_dir` is provided, the function extracts any binary resourc
59
61
 
60
62
  NOTE: For a comprehensive reference to the JSON manifest structure, see the [CAI manifest store reference](https://contentauth.github.io/json-manifest-reference/manifest-reference).
61
63
 
64
+ ### Add a signed manifest to a media file
65
+
66
+ Use the `sign_file` function to add a signed manifest to a media file.
67
+
68
+ ```py
69
+ result = c2pa.sign_file("path/to/source.jpg",
70
+ "path/to/dest.jpg",
71
+ manifest_json,
72
+ sign_info,
73
+ data_dir)
74
+ ```
75
+
76
+ The parameters (in order) are:
77
+ - The source (original) media file.
78
+ - The destination file that will contain a copy of the source file with the manifest data added.
79
+ - `manifest_json`, a JSON-formatted string containing the manifest data you want to add; see [Creating a manifest JSON definition file](#creating-a-manifest-json-definition-file) below.
80
+ - `sign_info`, a `SignerInfo` object instance; see [Generating SignerInfo](#generating-signerinfo) below.
81
+ - `data_dir` optionally specifies a directory path from which to load resource files referenced in the manifest JSON identifier fields; for example, thumbnails, icons, and manifest data for ingredients.
82
+
62
83
  ### Create a SignerInfo Instance
63
84
 
64
85
  A `SignerInfo` object contains information about a signature. To create an instance of `SignerInfo`, first set up the signer information from the public and private key `.pem` files as follows:
@@ -71,12 +92,12 @@ prv_key = open("path/to/private_key.pem","rb").read()
71
92
  Then create a new `SignerInfo` instance using the keys as follows, specifying the signing algorithm used and optionally a time stamp authority URL:
72
93
 
73
94
  ```py
74
- sign_info = c2pa.SignerInfo(certs, priv_key, "es256", "http://timestamp.digicert.com")
95
+ sign_info = c2pa.SignerInfo("es256", certs, priv_key, "http://timestamp.digicert.com")
75
96
  ```
76
97
 
77
98
  For the list of supported signing algorithms, see [Creating and using an X.509 certificate](https://opensource.contentauthenticity.org/docs/c2patool/x_509).
78
99
 
79
- ### Creating a manifest JSON definition
100
+ ### Creating a manifest JSON definition file
80
101
 
81
102
  The manifest JSON string defines the C2PA manifest to add to the file.
82
103
 
@@ -99,27 +120,6 @@ manifest_json = json.dumps({
99
120
  })
100
121
  ```
101
122
 
102
- ### Add a signed manifest to a media file
103
-
104
- Use the `add_manifest_to_file_json` function to add a signed manifest to a media file.
105
-
106
- ```py
107
- result = c2pa.add_manifest_to_file_json("path/to/source.jpg",
108
- "path/to/dest.jpg",
109
- manifest_json,
110
- sign_info,
111
- data_dir)
112
- ```
113
-
114
- The parameters (in order) are:
115
- - The source (original) media file.
116
- - The destination file that will contain a copy of the source file with the manifest data added.
117
- - `manifest_json`, a JSON-formatted string containing the manifest data you want to add; see [Creating a manifest JSON definition file](#creating-a-manifest-json-definition-file) below.
118
- - `sign_info`, a `SignerInfo` object instance; see [Generating SignerInfo](#generating-signerinfo) below.
119
- - `data_dir` optionally specifies a directory path from which to load resource files referenced in the manifest JSON identifier fields; for example, thumbnails, icons, and manifest data for ingredients.
120
-
121
- See [training.py](https://github.com/contentauth/c2pa-python/blob/main/tests/training.py) for an example.
122
-
123
123
  ## Development
124
124
 
125
125
  It is best to [set up a virtual environment](https://virtualenv.pypa.io/en/latest/installation.html) for development and testing.
@@ -142,8 +142,8 @@ pip install <path-to-whl> --force-reinstall
142
142
 
143
143
  We use [PyTest](https://docs.pytest.org/) for testing.
144
144
 
145
- With the venv virtual environment,
146
- run tests by entering these commands:
145
+ Run tests by entering this command:
146
+
147
147
  ```
148
148
  source .venv/bin/activate
149
149
  maturin develop
@@ -151,6 +151,16 @@ pytest
151
151
  deactivate
152
152
  ```
153
153
 
154
+ ### Example
155
+
156
+ Run the example code like this:
157
+
158
+ ```
159
+ source .venv/bin/activate
160
+ maturin develop
161
+ python3 tests/training.py
162
+ deactivate
163
+ ```
154
164
 
155
165
  ## Supported file formats
156
166
 
@@ -172,6 +182,19 @@ deactivate
172
182
  | `wav` | `audio/x-wav` |
173
183
  | `webp` | `image/webp` |
174
184
 
185
+
186
+ ## Change Notes:
187
+
188
+ Version 0.3.0 changes:
189
+ There are some breaking changes to align with future APIs:
190
+ - `C2paSignerInfo` moves the `alg` to the first parameter from the 3rd.
191
+ - `c2pa.verify_from_file_json` is now `c2pa.read_file`.
192
+ - `c2pa.ingredient_from_file_json` is now `c2pa.read_ingredient_file`.
193
+ - `c2pa.add_manifest_to_file_json` is now `c2pa.sign_file`.
194
+ - There are many more specific errors types now, and Error messages always start with the name of the error i.e (str(err.value).startswith("ManifestNotFound")).
195
+ - The ingredient thumbnail identifier may be jumbf uri reference if a valid thumb already exists in the active manifest.
196
+ - Extracted file paths for read_file now use a folder structure and different naming conventions.
197
+
175
198
  ## License
176
199
 
177
200
  This package is distributed under the terms of both the [MIT license](https://github.com/contentauth/c2pa-rs/blob/main/LICENSE-MIT) and the [Apache License (Version 2.0)](https://github.com/contentauth/c2pa-rs/blob/main/LICENSE-APACHE).
@@ -4,6 +4,8 @@ Python bindings for the C2PA Content Authenticity Initiative (CAI) library.
4
4
 
5
5
  This library enables you to read and validate C2PA data in supported media files and add signed manifests to supported media files.
6
6
 
7
+ **WARNING**: This is an early prerelease version of this library. There may be bugs and unimplemented features, and the API is subject to change.
8
+
7
9
  ## Installation
8
10
 
9
11
  Install from PyPI by entering this command:
@@ -24,10 +26,10 @@ import c2pa_python as c2pa
24
26
 
25
27
  ### Read and validate C2PA data in a file
26
28
 
27
- Use the `verify_from_file_json` function to read C2PA data from the specified file:
29
+ Use the `read_file` function to read C2PA data from the specified file:
28
30
 
29
31
  ```py
30
- json_store = c2pa.verify_from_file_json("path/to/media_file.jpg", "path/to/data_dir")
32
+ json_store = c2pa.read_file("path/to/media_file.jpg", "path/to/data_dir")
31
33
  ```
32
34
 
33
35
  This function examines the specified media file for C2PA data and generates a JSON report of any data it finds. If there are validation errors, the report includes a `validation_status` field. For a summary of supported media types, see [Supported file formats](#supported-file-formats).
@@ -38,6 +40,25 @@ If the optional `data_dir` is provided, the function extracts any binary resourc
38
40
 
39
41
  NOTE: For a comprehensive reference to the JSON manifest structure, see the [CAI manifest store reference](https://contentauth.github.io/json-manifest-reference/manifest-reference).
40
42
 
43
+ ### Add a signed manifest to a media file
44
+
45
+ Use the `sign_file` function to add a signed manifest to a media file.
46
+
47
+ ```py
48
+ result = c2pa.sign_file("path/to/source.jpg",
49
+ "path/to/dest.jpg",
50
+ manifest_json,
51
+ sign_info,
52
+ data_dir)
53
+ ```
54
+
55
+ The parameters (in order) are:
56
+ - The source (original) media file.
57
+ - The destination file that will contain a copy of the source file with the manifest data added.
58
+ - `manifest_json`, a JSON-formatted string containing the manifest data you want to add; see [Creating a manifest JSON definition file](#creating-a-manifest-json-definition-file) below.
59
+ - `sign_info`, a `SignerInfo` object instance; see [Generating SignerInfo](#generating-signerinfo) below.
60
+ - `data_dir` optionally specifies a directory path from which to load resource files referenced in the manifest JSON identifier fields; for example, thumbnails, icons, and manifest data for ingredients.
61
+
41
62
  ### Create a SignerInfo Instance
42
63
 
43
64
  A `SignerInfo` object contains information about a signature. To create an instance of `SignerInfo`, first set up the signer information from the public and private key `.pem` files as follows:
@@ -50,12 +71,12 @@ prv_key = open("path/to/private_key.pem","rb").read()
50
71
  Then create a new `SignerInfo` instance using the keys as follows, specifying the signing algorithm used and optionally a time stamp authority URL:
51
72
 
52
73
  ```py
53
- sign_info = c2pa.SignerInfo(certs, priv_key, "es256", "http://timestamp.digicert.com")
74
+ sign_info = c2pa.SignerInfo("es256", certs, priv_key, "http://timestamp.digicert.com")
54
75
  ```
55
76
 
56
77
  For the list of supported signing algorithms, see [Creating and using an X.509 certificate](https://opensource.contentauthenticity.org/docs/c2patool/x_509).
57
78
 
58
- ### Creating a manifest JSON definition
79
+ ### Creating a manifest JSON definition file
59
80
 
60
81
  The manifest JSON string defines the C2PA manifest to add to the file.
61
82
 
@@ -78,27 +99,6 @@ manifest_json = json.dumps({
78
99
  })
79
100
  ```
80
101
 
81
- ### Add a signed manifest to a media file
82
-
83
- Use the `add_manifest_to_file_json` function to add a signed manifest to a media file.
84
-
85
- ```py
86
- result = c2pa.add_manifest_to_file_json("path/to/source.jpg",
87
- "path/to/dest.jpg",
88
- manifest_json,
89
- sign_info,
90
- data_dir)
91
- ```
92
-
93
- The parameters (in order) are:
94
- - The source (original) media file.
95
- - The destination file that will contain a copy of the source file with the manifest data added.
96
- - `manifest_json`, a JSON-formatted string containing the manifest data you want to add; see [Creating a manifest JSON definition file](#creating-a-manifest-json-definition-file) below.
97
- - `sign_info`, a `SignerInfo` object instance; see [Generating SignerInfo](#generating-signerinfo) below.
98
- - `data_dir` optionally specifies a directory path from which to load resource files referenced in the manifest JSON identifier fields; for example, thumbnails, icons, and manifest data for ingredients.
99
-
100
- See [training.py](https://github.com/contentauth/c2pa-python/blob/main/tests/training.py) for an example.
101
-
102
102
  ## Development
103
103
 
104
104
  It is best to [set up a virtual environment](https://virtualenv.pypa.io/en/latest/installation.html) for development and testing.
@@ -121,8 +121,8 @@ pip install <path-to-whl> --force-reinstall
121
121
 
122
122
  We use [PyTest](https://docs.pytest.org/) for testing.
123
123
 
124
- With the venv virtual environment,
125
- run tests by entering these commands:
124
+ Run tests by entering this command:
125
+
126
126
  ```
127
127
  source .venv/bin/activate
128
128
  maturin develop
@@ -130,6 +130,16 @@ pytest
130
130
  deactivate
131
131
  ```
132
132
 
133
+ ### Example
134
+
135
+ Run the example code like this:
136
+
137
+ ```
138
+ source .venv/bin/activate
139
+ maturin develop
140
+ python3 tests/training.py
141
+ deactivate
142
+ ```
133
143
 
134
144
  ## Supported file formats
135
145
 
@@ -151,6 +161,19 @@ deactivate
151
161
  | `wav` | `audio/x-wav` |
152
162
  | `webp` | `image/webp` |
153
163
 
164
+
165
+ ## Change Notes:
166
+
167
+ Version 0.3.0 changes:
168
+ There are some breaking changes to align with future APIs:
169
+ - `C2paSignerInfo` moves the `alg` to the first parameter from the 3rd.
170
+ - `c2pa.verify_from_file_json` is now `c2pa.read_file`.
171
+ - `c2pa.ingredient_from_file_json` is now `c2pa.read_ingredient_file`.
172
+ - `c2pa.add_manifest_to_file_json` is now `c2pa.sign_file`.
173
+ - There are many more specific errors types now, and Error messages always start with the name of the error i.e (str(err.value).startswith("ManifestNotFound")).
174
+ - The ingredient thumbnail identifier may be jumbf uri reference if a valid thumb already exists in the active manifest.
175
+ - Extracted file paths for read_file now use a folder structure and different naming conventions.
176
+
154
177
  ## License
155
178
 
156
179
  This package is distributed under the terms of both the [MIT license](https://github.com/contentauth/c2pa-rs/blob/main/LICENSE-MIT) and the [Apache License (Version 2.0)](https://github.com/contentauth/c2pa-rs/blob/main/LICENSE-APACHE).
@@ -15,6 +15,9 @@ classifiers = [
15
15
  "Programming Language :: Python :: Implementation :: CPython",
16
16
  "Programming Language :: Python :: Implementation :: PyPy",
17
17
  ]
18
+ authors = [
19
+ {name = "Gavin Peacock", email = "gpeacock@adobe.com"}
20
+ ]
18
21
  maintainers = [
19
22
  {name = "Gavin Peacock", email = "gpeacock@adobe.com"}
20
23
  ]
@@ -0,0 +1,39 @@
1
+
2
+ namespace c2pa {
3
+ string version();
4
+ string sdk_version();
5
+ [Throws=Error]
6
+ string read_file([ByRef] string path, string? data_dir);
7
+ [Throws=Error]
8
+ string read_ingredient_file([ByRef] string path, [ByRef] string data_dir);
9
+ [Throws=Error]
10
+ sequence<u8> sign_file([ByRef] string source, [ByRef] string dest, [ByRef] string manifest, [ByRef] SignerInfo signer_info, string? data_dir);
11
+ };
12
+
13
+ [Error]
14
+ enum Error {
15
+ "Assertion",
16
+ "AssertionNotFound",
17
+ "Decoding",
18
+ "Encoding",
19
+ "FileNotFound",
20
+ "Io",
21
+ "Json",
22
+ "Manifest",
23
+ "ManifestNotFound",
24
+ "NotSupported",
25
+ "Other",
26
+ "NullParameter",
27
+ "RemoteManifest",
28
+ "ResourceNotFound",
29
+ "Signature",
30
+ "Verify"
31
+ };
32
+
33
+ dictionary SignerInfo {
34
+ string alg;
35
+ sequence<u8> sign_cert;
36
+ sequence<u8> private_key;
37
+ string? ta_url;
38
+ };
39
+
@@ -13,22 +13,13 @@
13
13
  /// This module exports a C2PA library
14
14
  use std::env;
15
15
 
16
- mod error;
17
- mod json_api;
18
- mod signer_info;
19
-
20
- pub use error::{Error, Result};
21
- pub use json_api::*;
22
- pub use signer_info::SignerInfo;
16
+ pub(crate) use c2pa_c::{
17
+ read_file, read_ingredient_file, sdk_version, sign_file, Error, SignerInfo,
18
+ };
23
19
 
24
20
  /// Returns the version of this library
25
21
  fn version() -> String {
26
22
  String::from(env!("CARGO_PKG_VERSION"))
27
23
  }
28
24
 
29
- /// Returns the version of the c2pa SDK used in this library
30
- fn sdk_version() -> String {
31
- String::from(c2pa::VERSION)
32
- }
33
-
34
25
  uniffi::include_scaffolding!("c2pa");
@@ -0,0 +1,34 @@
1
+ # Copyright 2023 Adobe. All rights reserved.
2
+ # This file is licensed to you under the Apache License,
3
+ # Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
4
+ # or the MIT license (http://opensource.org/licenses/MIT),
5
+ # at your option.
6
+ # Unless required by applicable law or agreed to in writing,
7
+ # this software is distributed on an "AS IS" BASIS, WITHOUT
8
+ # WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
9
+ # implied. See the LICENSE-MIT and LICENSE-APACHE files for the
10
+ # specific language governing permissions and limitations under
11
+ # each license.
12
+
13
+ # This example shows how to add a do not train assertion to an asset and then verify it
14
+
15
+ import json
16
+ import os
17
+ import sys
18
+ import c2pa_python as c2pa;
19
+
20
+ # set up paths to the files we we are using
21
+ PROJECT_PATH = os.getcwd()
22
+ testFile = os.path.join(PROJECT_PATH,"tests","fixtures","A.jpg")
23
+ pemFile = os.path.join(PROJECT_PATH,"tests","fixtures","es256_certs.pem")
24
+ keyFile = os.path.join(PROJECT_PATH,"tests","fixtures","es256_private.key")
25
+ testOutputFile = os.path.join(PROJECT_PATH,"target","dnt.jpg")
26
+
27
+ # a little helper function to get a value from a nested dictionary
28
+ from functools import reduce
29
+ import operator
30
+ def getitem(d, key):
31
+ return reduce(operator.getitem, key, d)
32
+
33
+ print("version = " + c2pa.version())
34
+
@@ -24,24 +24,24 @@ def getitem(d, key):
24
24
  return reduce(operator.getitem, key, d)
25
25
 
26
26
  def test_version():
27
- assert c2pa.version() == "0.2.2"
27
+ assert c2pa.version() == "0.3.0"
28
28
 
29
29
  def test_sdk_version():
30
- assert c2pa.sdk_version() == "0.26.0"
30
+ assert c2pa.sdk_version() == "0.28.3"
31
31
 
32
32
 
33
33
  def test_verify_from_file():
34
- json_store = c2pa.verify_from_file_json("tests/fixtures/C.jpg", None)
34
+ json_store = c2pa.read_file("tests/fixtures/C.jpg", None)
35
35
  assert not "validation_status" in json_store
36
36
 
37
37
  def test_verify_from_file_no_store():
38
- with pytest.raises(c2pa.Error.Sdk) as err:
39
- json_store = c2pa.verify_from_file_json("tests/fixtures/A.jpg", None)
40
- assert str(err.value) == "no JUMBF data found"
38
+ with pytest.raises(c2pa.Error.ManifestNotFound) as err:
39
+ json_store = c2pa.read_file("tests/fixtures/A.jpg", None)
40
+ assert str(err.value).startswith("ManifestNotFound")
41
41
 
42
42
  def test_verify_from_file_get_thumbnail():
43
43
  with tempfile.TemporaryDirectory() as data_dir:
44
- store_json = c2pa.verify_from_file_json("tests/fixtures/C.jpg", data_dir)
44
+ store_json = c2pa.read_file("tests/fixtures/C.jpg", data_dir)
45
45
  manifest_store = json.loads(store_json)
46
46
  manifest = manifest_store["manifests"][manifest_store["active_manifest"]]
47
47
  print (store_json)
@@ -67,18 +67,20 @@ def test_verify_from_file_get_thumbnail():
67
67
 
68
68
  def test_ingredient_from_file_get_thumbnail():
69
69
  with tempfile.TemporaryDirectory() as data_dir:
70
- ingredient_json = c2pa.ingredient_from_file_json("tests/fixtures/C.jpg", data_dir)
70
+ ingredient_json = c2pa.read_ingredient_file("tests/fixtures/C.jpg", data_dir)
71
71
  ingredient = json.loads(ingredient_json)
72
72
  assert ingredient["title"]== "C.jpg"
73
73
  assert ingredient,["format"] == "image/jpeg"
74
74
  # read thumbnail data from file
75
75
  assert getitem(ingredient,("thumbnail","format")) == "image/jpeg"
76
76
  thumb_name = getitem(ingredient,("thumbnail","identifier"))
77
- with open(data_dir + "/" + thumb_name, "rb") as thumb_file:
78
- thumb_data = thumb_file.read()
79
- assert len(thumb_data) == 31608
77
+ assert thumb_name.startswith("self#jumbf=")
78
+ # we won't get a thumbnail file generated if a valid one already exists in the store
79
+ # with open(data_dir + "/" + thumb_name, "rb") as thumb_file:
80
+ # thumb_data = thumb_file.read()
81
+ # assert len(thumb_data) == 31608
80
82
  #read c2pa data from file
81
- assert getitem(ingredient,("manifest_data","format")) == "c2pa"
83
+ assert getitem(ingredient,("manifest_data","format")) == "application/c2pa"
82
84
  data_name = getitem(ingredient,("manifest_data","identifier"))
83
85
  with open(data_dir + "/" + data_name, "rb") as c2pa_file:
84
86
  c2pa_data = c2pa_file.read()
@@ -88,9 +90,9 @@ def test_sign_info():
88
90
  # set up the signer info loading the pem and key files
89
91
  test_pem = open("tests/fixtures/es256_certs.pem","rb").read()
90
92
  test_key = open("tests/fixtures/es256_private.key","rb").read()
91
- sign_info = c2pa.SignerInfo(test_pem, test_key, "es256", "http://timestamp.digicert.com")
93
+ sign_info = c2pa.SignerInfo("es256", test_pem, test_key, "http://timestamp.digicert.com")
92
94
  assert sign_info.alg == "es256"
93
- assert sign_info.tsa_url == "http://timestamp.digicert.com"
95
+ assert sign_info.ta_url == "http://timestamp.digicert.com"
94
96
 
95
97
  def test_add_manifest_to_file():
96
98
  # define a source folder for any assets we need to read
@@ -124,14 +126,14 @@ def test_add_manifest_to_file():
124
126
  # set up the signer info loading the pem and key files
125
127
  test_pem = open("tests/fixtures/es256_certs.pem","rb").read()
126
128
  test_key = open("tests/fixtures/es256_private.key","rb").read()
127
- sign_info = c2pa.SignerInfo(test_pem, test_key, "es256", "http://timestamp.digicert.com")
129
+ sign_info = c2pa.SignerInfo("es256", test_pem, test_key, "http://timestamp.digicert.com")
128
130
 
129
131
  # add the manifest to the asset
130
- c2pa_data = c2pa.add_manifest_to_file_json(data_dir + "/A.jpg", output_dir+"/out.jpg", manifest_json, sign_info, data_dir)
132
+ c2pa_data = c2pa.sign_file(data_dir + "/A.jpg", output_dir+"/out.jpg", manifest_json, sign_info, data_dir)
131
133
  assert len(c2pa_data) == 75860 #check the size of returned c2pa_manifest data
132
134
 
133
135
  # verify the asset and check the manifest has what we expect
134
- store_json = c2pa.verify_from_file_json(output_dir + "/out.jpg", output_dir)
136
+ store_json = c2pa.read_file(output_dir + "/out.jpg", output_dir)
135
137
  manifest_store = json.loads(store_json)
136
138
  manifest = manifest_store["manifests"][manifest_store["active_manifest"]]
137
139
  print (store_json)
@@ -57,9 +57,9 @@ try:
57
57
  # set up the signer info loading the pem and key files
58
58
  test_pem = open(pemFile,"rb").read()
59
59
  test_key = open(keyFile,"rb").read()
60
- sign_info = c2pa.SignerInfo(test_pem, test_key, "es256", "http://timestamp.digicert.com")
60
+ sign_info = c2pa.SignerInfo("es256", test_pem, test_key, "http://timestamp.digicert.com")
61
61
 
62
- result = c2pa.add_manifest_to_file_json(testFile, testOutputFile, manifest_json, sign_info, None)
62
+ result = c2pa.sign_file(testFile, testOutputFile, manifest_json, sign_info, None)
63
63
 
64
64
  except Exception as err:
65
65
  sys.exit(err)
@@ -71,7 +71,7 @@ print("successfully added do not train manifest to file " + testOutputFile)
71
71
 
72
72
  allowed = True # opt out model, assume training is ok if the assertion doesn't exist
73
73
  try:
74
- json_store = c2pa.verify_from_file_json(testOutputFile, None)
74
+ json_store = c2pa.read_file(testOutputFile, None)
75
75
  manifest_store = json.loads(json_store)
76
76
 
77
77
  manifest = manifest_store["manifests"][manifest_store["active_manifest"]]
@@ -1,25 +0,0 @@
1
-
2
- namespace c2pa {
3
- string version();
4
- string sdk_version();
5
- [Throws=Error]
6
- string verify_from_file_json([ByRef] string path, string? data_dir);
7
- [Throws=Error]
8
- string ingredient_from_file_json([ByRef] string path, [ByRef] string data_dir);
9
- [Throws=Error]
10
- sequence<u8> add_manifest_to_file_json([ByRef] string source, [ByRef] string dest, [ByRef] string manifest, SignerInfo signer_info, string? data_dir);
11
- };
12
-
13
- [Error]
14
- enum Error {
15
- "Json",
16
- "Sdk"
17
- };
18
-
19
- dictionary SignerInfo {
20
- sequence<u8> signcert;
21
- sequence<u8> pkey;
22
- string alg;
23
- string? tsa_url;
24
- };
25
-
@@ -1,42 +0,0 @@
1
- // Copyright 2022 Adobe. All rights reserved.
2
- // This file is licensed to you under the Apache License,
3
- // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
4
- // or the MIT license (http://opensource.org/licenses/MIT),
5
- // at your option.
6
-
7
- // Unless required by applicable law or agreed to in writing,
8
- // this software is distributed on an "AS IS" BASIS, WITHOUT
9
- // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
10
- // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
11
- // specific language governing permissions and limitations under
12
- // each license.
13
-
14
- // Copyright 2023 Adobe. All rights reserved.
15
- // This file is licensed to you under the Apache License,
16
- // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
17
- // or the MIT license (http://opensource.org/licenses/MIT),
18
- // at your option.
19
- // Unless required by applicable law or agreed to in writing,
20
- // this software is distributed on an "AS IS" BASIS, WITHOUT
21
- // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
22
- // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
23
- // specific language governing permissions and limitations under
24
- // each license.
25
-
26
- use c2pa;
27
- use serde_json;
28
- use thiserror::Error;
29
-
30
- pub type Result<T> = std::result::Result<T, Error>;
31
-
32
- #[derive(Error, Debug)]
33
- /// Defines all possible errors that can occur in this library
34
- pub enum Error {
35
- #[error(transparent)]
36
- /// An error occurred while parsing a JSON string
37
- Json(#[from] serde_json::Error),
38
-
39
- #[error(transparent)]
40
- /// An error occurred while using the c2pa SDK
41
- Sdk(#[from] c2pa::Error),
42
- }
@@ -1,107 +0,0 @@
1
- // Copyright 2023 Adobe. All rights reserved.
2
- // This file is licensed to you under the Apache License,
3
- // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
4
- // or the MIT license (http://opensource.org/licenses/MIT),
5
- // at your option.
6
- // Unless required by applicable law or agreed to in writing,
7
- // this software is distributed on an "AS IS" BASIS, WITHOUT
8
- // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
9
- // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
10
- // specific language governing permissions and limitations under
11
- // each license.
12
-
13
- use c2pa::{Ingredient, Manifest, ManifestStore};
14
-
15
- use crate::{Error, Result, SignerInfo};
16
-
17
- /// Returns ManifestStore JSON string from a file path.
18
- ///
19
- /// If data_dir is provided, any thumbnail or c2pa data will be written to that folder.
20
- /// Any Validation errors will be reported in the validation_status field.
21
- ///
22
- pub fn verify_from_file_json(path: &str, data_dir: Option<String>) -> Result<String> {
23
- Ok(match data_dir {
24
- Some(dir) => ManifestStore::from_file_with_resources(path, &dir),
25
- None => ManifestStore::from_file(path),
26
- }
27
- .map_err(Error::Sdk)?
28
- .to_string())
29
- }
30
-
31
- /// Returns an Ingredient JSON string from a file path.
32
- ///
33
- /// Any thumbnail or c2pa data will be written to data_dir if provided
34
- pub fn ingredient_from_file_json(path: &str, data_dir: &str) -> Result<String> {
35
- Ok(Ingredient::from_file_with_folder(path, data_dir)
36
- .map_err(Error::Sdk)?
37
- .to_string())
38
- }
39
-
40
- /// Adds a manifest to the source file and writes the result to the destination file.
41
- /// Also returns the binary manifest data for optional cloud storage
42
- /// A manifest definition must be supplied
43
- /// Signer information must also be supplied
44
- ///
45
- /// Any file paths in the manifest will be read relative to the source file
46
- pub fn add_manifest_to_file_json(
47
- source: &str,
48
- dest: &str,
49
- manifest_info: &str,
50
- signer_info: SignerInfo,
51
- data_dir: Option<String>,
52
- ) -> Result<Vec<u8>> {
53
- let mut manifest = Manifest::from_json(manifest_info).map_err(Error::Sdk)?;
54
-
55
- // if data_dir is provided, set the base path for the manifest
56
- if let Some(path) = data_dir {
57
- manifest.with_base_path(path).map_err(Error::Sdk)?;
58
- }
59
-
60
- // If the source file has a manifest store, and no parent is specified, treat the source's manifest store as the parent.
61
- if manifest.parent().is_none() {
62
- let source_ingredient = Ingredient::from_file(source).map_err(Error::Sdk)?;
63
- if source_ingredient.manifest_data().is_some() {
64
- manifest.set_parent(source_ingredient).map_err(Error::Sdk)?;
65
- }
66
- }
67
-
68
- let signer = signer_info.signer()?;
69
- manifest.embed(&source, &dest, &*signer).map_err(Error::Sdk)
70
- }
71
-
72
- #[cfg(test)]
73
- mod tests {
74
- use super::*;
75
- use std::{fs::remove_dir_all, path::PathBuf};
76
-
77
- /// returns a path to a file in the fixtures folder
78
- pub fn test_path(path: &str) -> String {
79
- let base = env!("CARGO_MANIFEST_DIR");
80
- format!("{}/{}", base, path)
81
- }
82
-
83
- #[test]
84
- fn test_verify_from_file_no_base() {
85
- let path = test_path("tests/fixtures/C.jpg");
86
- let result = verify_from_file_json(&path, None);
87
- assert!(result.is_ok());
88
- let json_report = result.unwrap();
89
- println!("{}", json_report);
90
- assert!(json_report.contains("C.jpg"));
91
- //assert!(!json_report.contains("validation_status"));
92
- }
93
-
94
- #[test]
95
- fn test_verify_from_file_with_base() {
96
- let path = test_path("tests/fixtures/C.jpg");
97
- let data_dir = "target/data_dir";
98
- remove_dir_all(data_dir).unwrap();
99
- let result = verify_from_file_json(&path, Some(data_dir.to_owned()));
100
- assert!(result.is_ok());
101
- let json_report = result.unwrap();
102
- println!("{}", json_report);
103
- assert!(json_report.contains("C.jpg"));
104
- assert!(PathBuf::from(data_dir).exists());
105
- assert!(json_report.contains("thumbnail"));
106
- }
107
- }
@@ -1,58 +0,0 @@
1
- // Copyright 2023 Adobe. All rights reserved.
2
- // This file is licensed to you under the Apache License,
3
- // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
4
- // or the MIT license (http://opensource.org/licenses/MIT),
5
- // at your option.
6
- // Unless required by applicable law or agreed to in writing,
7
- // this software is distributed on an "AS IS" BASIS, WITHOUT
8
- // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
9
- // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
10
- // specific language governing permissions and limitations under
11
- // each license.
12
-
13
- use c2pa::{create_signer, Signer, SigningAlg};
14
- use serde::Deserialize;
15
-
16
- use crate::{Error, Result};
17
-
18
- /// SignerInfo provides the information needed to create a signer
19
- /// and sign a manifest.
20
- ///
21
- /// The signer is created from the signcert and pkey fields.
22
- ///
23
- /// The alg field is used to determine the signing algorithm.
24
- ///
25
- /// The tsa_url field is optional and is used to specify a timestamp server.
26
- ///
27
- #[derive(Clone, Debug, Deserialize)]
28
- pub struct SignerInfo {
29
- pub signcert: Vec<u8>,
30
- pub pkey: Vec<u8>,
31
- pub alg: String,
32
- pub tsa_url: Option<String>,
33
- }
34
- impl SignerInfo {
35
- /// Create a SignerInfo from a JSON formatted SignerInfo string
36
- pub fn from_json(json: &str) -> Result<Self> {
37
- serde_json::from_str(json).map_err(Error::Json)
38
- }
39
-
40
- // Returns the signing algorithm converted from string format
41
- fn alg(&self) -> Result<SigningAlg> {
42
- self.alg
43
- .to_lowercase()
44
- .parse()
45
- .map_err(|_| Error::Sdk(c2pa::Error::UnsupportedType))
46
- }
47
-
48
- /// Create a signer from the SignerInfo
49
- pub fn signer(&self) -> Result<Box<dyn Signer>> {
50
- create_signer::from_keys(
51
- &self.signcert,
52
- &self.pkey,
53
- self.alg()?,
54
- self.tsa_url.clone(),
55
- )
56
- .map_err(Error::Sdk)
57
- }
58
- }
File without changes
File without changes
File without changes
File without changes
File without changes