Struct ipworksllm::C2PASigner
Properties Methods Events Config Settings Errors
Creates a C2PA Manifest, signs it, and embeds it into an asset.
Syntax
ipworksllm::C2PASigner
Remarks
The C2PASigner struct produces Content Credentials: a signed C2PA Manifest that records how an asset was produced, which tool produced it, and whether generative AI was involved. The manifest is embedded directly into the asset, so the provenance travels with the file.
Supported Formats
The struct embeds the manifest into the asset itself, so each container format needs its own support. JPEG, PNG and PDF are supported.
| JPEG | The manifest travels in APP11 marker segments. Because a JPEG marker segment cannot exceed 64K, a manifest of any size spans several contiguous segments. |
| PNG | The manifest travels in a single caBX chunk placed before the image data. |
| The manifest travels in an embedded file stream, appended to the document as an incremental update. The original bytes of the document are left untouched. |
The format is detected from the asset itself; there is nothing to configure. An asset in any other format is refused rather than written incorrectly.
For PDF, only documents using classic cross-reference tables can be signed. A document using cross-reference streams is refused, because appending a table-style update to it would produce a file that readers reject.
Signing an Asset
Set input_file to the asset to be signed, output_file to the destination, and signing_cert to a certificate with an associated private key. Calling sign builds the manifest, signs it, and writes the result.
C2PASigner signer = new C2PASigner();
signer.InputFile = "photo.jpg";
signer.OutputFile = "photo-signed.jpg";
signer.ClaimGenerator = "MyApp/1.0";
signer.SigningCert = new Certificate(CertStoreTypes.cstPFXFile, "signer.pfx", "password", "*");
signer.Sign();
The signing certificate must carry the C2PA claim signing extended key usage, and the manifest is signed with the algorithm named by signature_algorithm. The permitted algorithms are ES256, ES384, ES512, PS256, PS384, PS512, and Ed25519; the C2PA specification permits no others.
Disclosing AI-Generated Content
The most common reason to sign an asset is to disclose how it was created. The add_action method records a single action in the manifest. Marking an asset as generative AI output is one call.
signer.AddAction("c2pa.created",
"http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia",
"MyApp/1.0");
signer.Sign();
The second parameter is the digital source type. The C2PA specification requires that a digital source type accompany the c2pa.created action for every asset; use http://c2pa.org/digitalsourcetype/empty when the asset began as a new file with no digital content.
Adding Other Assertions
Anything beyond the assertions the struct computes for itself is added with add_assertion, which appends a raw assertion payload under a given label. This keeps the API stable as the C2PA standard assertion set evolves.
string creativeWork = "{\"@context\":\"https://schema.org\",\"@type\":\"CreativeWork\",\"author\":[{\"@type\":\"Person\",\"name\":\"Jane Doe\"}]}";
signer.AddAssertion("stds.schema-org.CreativeWork", "application/json",
System.Text.Encoding.UTF8.GetBytes(creativeWork));
The content binding assertion, which cryptographically ties the manifest to the asset bytes, is always computed by the struct and cannot be supplied by the application. Doing so is what makes tampering detectable.
Trusted Time-Stamps
Setting tsaurl to the address of an RFC 3161 Time Stamping Authority adds a trusted time-stamp to the signature. A time-stamped signature remains verifiable after the signing certificate expires, which is why the C2PA specification recommends obtaining one whenever a TSA can be reached.
signer.TSAURL = "http://timestamp.example.com/tsa";
signer.Sign();
Object Lifetime
The new() method returns a mutable reference to a struct instance. The object itself is kept in the global list maintained by IPWorksLLM. Due to this, the C2PASigner struct cannot be disposed of automatically. Please, call the dispose(&self) method of C2PASigner when you have finished using the instance.
Property List
The following is the full list of the properties of the struct with short descriptions. Click on the links for further details.
| action_count | The number of records in the Action arrays. |
| action | The action identifier. |
| action_digital_source_type | The nature of the content the action produced. |
| action_software_agent | The tool that performed the action. |
| action_when | When the action took place. |
| assertion_count | The number of records in the Assertion arrays. |
| assertion_label | The assertion label. |
| assertion_data | The assertion payload. |
| assertion_media_type | The media type of the assertion payload. |
| claim_generator | The identifier of the tool that created the claim. |
| ingredient_count | The number of records in the Ingredient arrays. |
| ingredient_format | The media type of the ingredient asset. |
| ingredient_instance_id | The instance identifier of the ingredient asset. |
| ingredient_manifest_label | The label of the ingredient's own C2PA Manifest. |
| ingredient_relationship | How the ingredient relates to the asset. |
| ingredient_title | A human-readable name for the ingredient. |
| input_data | The asset to process, held in memory. |
| input_file | The asset to process. |
| output_data | The signed asset, held in memory. |
| output_file | The file to write the signed asset to. |
| overwrite | Whether the struct may overwrite an existing output file. |
| signature_algorithm | The algorithm used to sign the claim. |
| signing_cert_effective_date | The date on which this certificate becomes valid. |
| signing_cert_expiration_date | The date on which the certificate expires. |
| signing_cert_extended_key_usage | A comma-delimited list of extended key usage identifiers. |
| signing_cert_fingerprint | The hex-encoded, 16-byte MD5 fingerprint of the certificate. |
| signing_cert_fingerprint_sha1 | The hex-encoded, 20-byte SHA-1 fingerprint of the certificate. |
| signing_cert_fingerprint_sha256 | The hex-encoded, 32-byte SHA-256 fingerprint of the certificate. |
| signing_cert_issuer | The issuer of the certificate. |
| signing_cert_private_key | The private key of the certificate (if available). |
| signing_cert_private_key_available | Whether a PrivateKey is available for the selected certificate. |
| signing_cert_private_key_container | The name of the PrivateKey container for the certificate (if available). |
| signing_cert_public_key | The public key of the certificate. |
| signing_cert_public_key_algorithm | The textual description of the certificate's public key algorithm. |
| signing_cert_public_key_length | The length of the certificate's public key (in bits). |
| signing_cert_serial_number | The serial number of the certificate encoded as a string. |
| signing_cert_signature_algorithm | The text description of the certificate's signature algorithm. |
| signing_cert_store | The name of the certificate store for the client certificate. |
| signing_cert_store_password | If the type of certificate store requires a password, this property is used to specify the password needed to open the certificate store. |
| signing_cert_store_type | The type of certificate store for this certificate. |
| signing_cert_subject_alt_names | Comma-separated lists of alternative subject names for the certificate. |
| signing_cert_thumbprint_md5 | The MD5 hash of the certificate. |
| signing_cert_thumbprint_sha1 | The SHA-1 hash of the certificate. |
| signing_cert_thumbprint_sha256 | The SHA-256 hash of the certificate. |
| signing_cert_usage | The text description of UsageFlags . |
| signing_cert_usage_flags | The flags that show intended use for the certificate. |
| signing_cert_version | The certificate's version number. |
| signing_cert_subject | The subject of the certificate used for client authentication. |
| signing_cert_encoded | The certificate (PEM/Base64 encoded). |
| tsaurl | The address of an RFC 3161 Time Stamping Authority. |
Method List
The following is the full list of the methods of the struct with short descriptions. Click on the links for further details.
| add_action | Records an action in the C2PA Manifest. |
| add_assertion | Appends an assertion to the Assertions collection. |
| add_ingredient | Records that an asset went into the one being signed. |
| config | Sets or retrieves a configuration setting. |
| reset | This method will reset the struct. |
| sign | Builds, signs, and embeds a C2PA Manifest. |
Event List
The following is the full list of the events fired by the struct with short descriptions. Click on the links for further details.
| on_error | Fired when information is available about errors during data delivery. |
| on_log | This event fires once for each log message. |
Config Settings
The following is a list of config settings for the struct with short descriptions. Click on the links for further details.
| HashAlgorithm | The hash algorithm used for the content binding. |
| IncludeThumbnail | Whether a claim thumbnail is embedded in the manifest. |
| InstanceId | The instance identifier recorded in the claim. |
| LogLevel | The level of detail logged through the Log event. |
| SignaturePadding | The number of bytes reserved for the claim signature. |
| BuildInfo | Information about the product's build. |
| CodePage | The system code page used for Unicode to Multibyte translations. |
| LicenseInfo | Information about the current license. |
| MaskSensitiveData | Whether sensitive data is masked in log messages. |
| UseInternalSecurityAPI | Whether or not to use the system security libraries or an internal implementation. |
action_count property (C2PASigner Struct)
The number of records in the Action arrays.
Syntax
fn action_count(&self) -> Result<i32, IPWorksLLMError>
fn set_action_count(&self, value : i32) -> Option<IPWorksLLMError>
Default Value
0
Remarks
This property controls the size of the following arrays:
The array indices start at 0 and end at action_count - 1.Data Type
i32
action property (C2PASigner Struct)
The action identifier.
Syntax
fn action(&self, ActionIndex : i32) -> Result<String, IPWorksLLMError>
fn set_action(&self, ActionIndex : i32, value : &str) -> Option<IPWorksLLMError> fn set_action_ref(&self, ActionIndex : i32, value : &String) -> Option<IPWorksLLMError>
Default Value
""
Remarks
This field holds the C2PA action identifier. Values defined by the specification include c2pa.created, c2pa.edited, c2pa.opened, c2pa.placed, c2pa.converted, and c2pa.published.
The first action in a manifest describes how the asset came into being, and is normally c2pa.created.
The ActionIndex parameter specifies the index of the item in the array. The size of the array is controlled by the action_count property.
Data Type
String
action_digital_source_type property (C2PASigner Struct)
The nature of the content the action produced.
Syntax
fn action_digital_source_type(&self, ActionIndex : i32) -> Result<String, IPWorksLLMError>
fn set_action_digital_source_type(&self, ActionIndex : i32, value : &str) -> Option<IPWorksLLMError> fn set_action_digital_source_type_ref(&self, ActionIndex : i32, value : &String) -> Option<IPWorksLLMError>
Default Value
""
Remarks
This field identifies what kind of content resulted from the action, using a term from the IPTC digital source type vocabulary or one of the C2PA-specific values.
The C2PA specification requires that a digital source type accompany the c2pa.created action for every asset. Commonly used values are:
| http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia | Media produced by a generative model. |
| http://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture | Captured by a camera or other recording device. |
| http://cv.iptc.org/newscodes/digitalsourcetype/compositeWithTrainedAlgorithmicMedia | A composite that includes generated elements. |
| http://c2pa.org/digitalsourcetype/empty | The asset began as a new file with no digital content. |
No digital source type is required with a c2pa.opened action.
The ActionIndex parameter specifies the index of the item in the array. The size of the array is controlled by the action_count property.
Data Type
String
action_software_agent property (C2PASigner Struct)
The tool that performed the action.
Syntax
fn action_software_agent(&self, ActionIndex : i32) -> Result<String, IPWorksLLMError>
fn set_action_software_agent(&self, ActionIndex : i32, value : &str) -> Option<IPWorksLLMError> fn set_action_software_agent_ref(&self, ActionIndex : i32, value : &String) -> Option<IPWorksLLMError>
Default Value
""
Remarks
This field names the software that carried out the action, for example MyApp/1.0.
It answers a different question from the manifest's claim generator: the claim generator is whatever wrote the provenance data, while this field is whatever actually edited the asset. They are often, but not always, the same tool.
The ActionIndex parameter specifies the index of the item in the array. The size of the array is controlled by the action_count property.
Data Type
String
action_when property (C2PASigner Struct)
When the action took place.
Syntax
fn action_when(&self, ActionIndex : i32) -> Result<String, IPWorksLLMError>
fn set_action_when(&self, ActionIndex : i32, value : &str) -> Option<IPWorksLLMError> fn set_action_when_ref(&self, ActionIndex : i32, value : &String) -> Option<IPWorksLLMError>
Default Value
""
Remarks
This field holds the time the action was performed, as an RFC 3339 date and time.
The C2PA specification requires an explicit timezone or a trailing Z for UTC. When this field is left empty, no time is recorded for the action.
Note that this is a claimed time, asserted by whoever signed the manifest. It is not the same as a trusted time-stamp, which is obtained from a Time Stamping Authority and is what a validator relies on to establish when the signature actually existed.
The ActionIndex parameter specifies the index of the item in the array. The size of the array is controlled by the action_count property.
Data Type
String
assertion_count property (C2PASigner Struct)
The number of records in the Assertion arrays.
Syntax
fn assertion_count(&self) -> Result<i32, IPWorksLLMError>
fn set_assertion_count(&self, value : i32) -> Option<IPWorksLLMError>
Default Value
0
Remarks
This property controls the size of the following arrays:
The array indices start at 0 and end at assertion_count - 1.Data Type
i32
assertion_label property (C2PASigner Struct)
The assertion label.
Syntax
fn assertion_label(&self, AssertionIndex : i32) -> Result<String, IPWorksLLMError>
fn set_assertion_label(&self, AssertionIndex : i32, value : &str) -> Option<IPWorksLLMError> fn set_assertion_label_ref(&self, AssertionIndex : i32, value : &String) -> Option<IPWorksLLMError>
Default Value
""
Remarks
This field holds the C2PA assertion label, which identifies what kind of statement the assertion makes and therefore how assertion_data should be interpreted.
Examples are c2pa.actions.v2, c2pa.hash.data, stds.schema-org.CreativeWork, and stds.exif.
The AssertionIndex parameter specifies the index of the item in the array. The size of the array is controlled by the assertion_count property.
Data Type
String
assertion_data property (C2PASigner Struct)
The assertion payload.
Syntax
fn assertion_data(&self, AssertionIndex : i32) -> Result<Vec<u8>, IPWorksLLMError>
fn set_assertion_data(&self, AssertionIndex : i32, value : Vec<u8>) -> Option<IPWorksLLMError> fn set_assertion_data_ref(&self, AssertionIndex : i32, value : &[u8]) -> Option<IPWorksLLMError>
Default Value
""
Remarks
This field holds the assertion's payload, encoded according to assertion_media_type.
The payload is passed through verbatim in both directions. An application can therefore write assertion types the component has no built-in knowledge of, and read back ones added to the standard after the component was built.
The AssertionIndex parameter specifies the index of the item in the array. The size of the array is controlled by the assertion_count property.
Data Type
Vec<u8>
assertion_media_type property (C2PASigner Struct)
The media type of the assertion payload.
Syntax
fn assertion_media_type(&self, AssertionIndex : i32) -> Result<String, IPWorksLLMError>
fn set_assertion_media_type(&self, AssertionIndex : i32, value : &str) -> Option<IPWorksLLMError> fn set_assertion_media_type_ref(&self, AssertionIndex : i32, value : &String) -> Option<IPWorksLLMError>
Default Value
"application/cbor"
Remarks
This field holds the media type of assertion_data, normally application/cbor or application/json.
The C2PA specification requires that assertions it defines be serialized as CBOR, so application/cbor is the default.
The AssertionIndex parameter specifies the index of the item in the array. The size of the array is controlled by the assertion_count property.
Data Type
String
claim_generator property (C2PASigner Struct)
The identifier of the tool that created the claim.
Syntax
fn claim_generator(&self) -> Result<String, IPWorksLLMError>
fn set_claim_generator(&self, value : &str) -> Option<IPWorksLLMError> fn set_claim_generator_ref(&self, value : &String) -> Option<IPWorksLLMError>
Default Value
""
Remarks
This property identifies the application that produced the C2PA Manifest, and is recorded in the claim so a consumer can see which tool made the provenance assertion.
Use a name and version, for example MyApp/1.0. When this property is left empty, the struct records its own name and version.
Data Type
String
ingredient_count property (C2PASigner Struct)
The number of records in the Ingredient arrays.
Syntax
fn ingredient_count(&self) -> Result<i32, IPWorksLLMError>
fn set_ingredient_count(&self, value : i32) -> Option<IPWorksLLMError>
Default Value
0
Remarks
This property controls the size of the following arrays:
- ingredient_format
- ingredient_instance_id
- ingredient_manifest_label
- ingredient_relationship
- ingredient_title
Data Type
i32
ingredient_format property (C2PASigner Struct)
The media type of the ingredient asset.
Syntax
fn ingredient_format(&self, IngredientIndex : i32) -> Result<String, IPWorksLLMError>
fn set_ingredient_format(&self, IngredientIndex : i32, value : &str) -> Option<IPWorksLLMError> fn set_ingredient_format_ref(&self, IngredientIndex : i32, value : &String) -> Option<IPWorksLLMError>
Default Value
""
Remarks
This field holds the media type of the asset that went into this one, for example image/jpeg, image/png or application/pdf. The component fills it in from the source asset when the ingredient is added.
The IngredientIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ingredient_count property.
Data Type
String
ingredient_instance_id property (C2PASigner Struct)
The instance identifier of the ingredient asset.
Syntax
fn ingredient_instance_id(&self, IngredientIndex : i32) -> Result<String, IPWorksLLMError>
fn set_ingredient_instance_id(&self, IngredientIndex : i32, value : &str) -> Option<IPWorksLLMError> fn set_ingredient_instance_id_ref(&self, IngredientIndex : i32, value : &String) -> Option<IPWorksLLMError>
Default Value
""
Remarks
This field holds the identifier of the exact version of the asset that went into this one, normally an XMP instance identifier such as xmp:iid:....
When the ingredient carried a C2PA Manifest of its own, the component fills this in from that Manifest's claim, so the reference names the precise version that was used rather than the document in general.
Version 2 of the ingredient assertion also carried a document identifier. Version 3, which this component writes, removed it, so there is no corresponding field.
The IngredientIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ingredient_count property.
Data Type
String
ingredient_manifest_label property (C2PASigner Struct)
The label of the ingredient's own C2PA Manifest.
Syntax
fn ingredient_manifest_label(&self, IngredientIndex : i32) -> Result<String, IPWorksLLMError>
fn set_ingredient_manifest_label(&self, IngredientIndex : i32, value : &str) -> Option<IPWorksLLMError> fn set_ingredient_manifest_label_ref(&self, IngredientIndex : i32, value : &String) -> Option<IPWorksLLMError>
Default Value
""
Remarks
This field identifies the manifest that describes the ingredient, when the ingredient carried one. It is the urn:c2pa label of that manifest within the same manifest store.
An empty value means the ingredient arrived without provenance data of its own.
The IngredientIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ingredient_count property.
Data Type
String
ingredient_relationship property (C2PASigner Struct)
How the ingredient relates to the asset.
Syntax
fn ingredient_relationship(&self, IngredientIndex : i32) -> Result<String, IPWorksLLMError>
fn set_ingredient_relationship(&self, IngredientIndex : i32, value : &str) -> Option<IPWorksLLMError> fn set_ingredient_relationship_ref(&self, IngredientIndex : i32, value : &String) -> Option<IPWorksLLMError>
Default Value
"componentOf"
Remarks
This field describes the ingredient's role. The C2PA specification defines the following values:
| parentOf | The asset is a derivative of this ingredient. There is at most one parent. |
| componentOf | The ingredient was placed into the asset alongside other content. |
| inputTo | The ingredient was consumed as input, for example as a prompt or a training input, without appearing in the result. |
The default value is componentOf.
The IngredientIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ingredient_count property.
Data Type
String
ingredient_title property (C2PASigner Struct)
A human-readable name for the ingredient.
Syntax
fn ingredient_title(&self, IngredientIndex : i32) -> Result<String, IPWorksLLMError>
fn set_ingredient_title(&self, IngredientIndex : i32, value : &str) -> Option<IPWorksLLMError> fn set_ingredient_title_ref(&self, IngredientIndex : i32, value : &String) -> Option<IPWorksLLMError>
Default Value
""
Remarks
This field holds a title for the ingredient asset, typically its filename, so a consumer can present the provenance chain in terms a person recognises.
The IngredientIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ingredient_count property.
Data Type
String
input_data property (C2PASigner Struct)
The asset to process, held in memory.
Syntax
fn input_data(&self) -> Result<Vec<u8>, IPWorksLLMError>
fn set_input_data(&self, value : Vec<u8>) -> Option<IPWorksLLMError> fn set_input_data_ref(&self, value : &[u8]) -> Option<IPWorksLLMError>
Default Value
""
Remarks
This property specifies the asset to be processed as a byte array, for applications that do not work with files on disk.
When both input_file and this property are set, input_file takes precedence.
Data Type
Vec<u8>
input_file property (C2PASigner Struct)
The asset to process.
Syntax
fn input_file(&self) -> Result<String, IPWorksLLMError>
fn set_input_file(&self, value : &str) -> Option<IPWorksLLMError> fn set_input_file_ref(&self, value : &String) -> Option<IPWorksLLMError>
Default Value
""
Remarks
This property specifies the asset to be processed. Set it to the full or relative path of the file.
When both this property and input_data are set, this property takes precedence.
Data Type
String
output_data property (C2PASigner Struct)
The signed asset, held in memory.
Syntax
fn output_data(&self) -> Result<Vec<u8>, IPWorksLLMError>
Default Value
""
Remarks
This property holds the signed asset after the operation completes, when output_file was left empty.
This property is read-only.
Data Type
Vec<u8>
output_file property (C2PASigner Struct)
The file to write the signed asset to.
Syntax
fn output_file(&self) -> Result<String, IPWorksLLMError>
fn set_output_file(&self, value : &str) -> Option<IPWorksLLMError> fn set_output_file_ref(&self, value : &String) -> Option<IPWorksLLMError>
Default Value
""
Remarks
This property specifies where the signed asset is written. Set it to the full or relative path of the destination file.
If this property is empty, the signed asset is written to output_data instead.
An error is thrown if the file already exists and overwrite is False.
Data Type
String
overwrite property (C2PASigner Struct)
Whether the struct may overwrite an existing output file.
Syntax
fn overwrite(&self) -> Result<bool, IPWorksLLMError>
fn set_overwrite(&self, value : bool) -> Option<IPWorksLLMError>
Default Value
false
Remarks
This property indicates whether the struct will overwrite output_file. When it is False, an error is thrown if output_file already exists.
The default value is False.
Data Type
bool
signature_algorithm property (C2PASigner Struct)
The algorithm used to sign the claim.
Syntax
fn signature_algorithm(&self) -> Result<String, IPWorksLLMError>
fn set_signature_algorithm(&self, value : &str) -> Option<IPWorksLLMError> fn set_signature_algorithm_ref(&self, value : &String) -> Option<IPWorksLLMError>
Default Value
"ES256"
Remarks
This property specifies the signature algorithm. The C2PA specification permits only the following values, and no others:
| ES256 | ECDSA with SHA-256. |
| ES384 | ECDSA with SHA-384. |
| ES512 | ECDSA with SHA-512. |
| PS256 | RSASSA-PSS using SHA-256 and MGF1 with SHA-256. |
| PS384 | RSASSA-PSS using SHA-384 and MGF1 with SHA-384. |
| PS512 | RSASSA-PSS using SHA-512 and MGF1 with SHA-512. |
| Ed25519 | EdDSA on the edwards25519 curve. No other EdDSA instance is allowed. |
The value must be compatible with the key in signing_cert. The default value is ES256.
Data Type
String
signing_cert_effective_date property (C2PASigner Struct)
The date on which this certificate becomes valid.
Syntax
fn signing_cert_effective_date(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
The date on which this certificate becomes valid. Before this date, it is not valid. The date is localized to the system's time zone. The following example illustrates the format of an encoded date:
23-Jan-2000 15:00:00.
This property is read-only.
Data Type
String
signing_cert_expiration_date property (C2PASigner Struct)
The date on which the certificate expires.
Syntax
fn signing_cert_expiration_date(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
The date on which the certificate expires. After this date, the certificate will no longer be valid. The date is localized to the system's time zone. The following example illustrates the format of an encoded date:
23-Jan-2001 15:00:00.
This property is read-only.
Data Type
String
signing_cert_extended_key_usage property (C2PASigner Struct)
A comma-delimited list of extended key usage identifiers.
Syntax
fn signing_cert_extended_key_usage(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
A comma-delimited list of extended key usage identifiers. These are the same as ASN.1 object identifiers (OIDs).
This property is read-only.
Data Type
String
signing_cert_fingerprint property (C2PASigner Struct)
The hex-encoded, 16-byte MD5 fingerprint of the certificate.
Syntax
fn signing_cert_fingerprint(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
The hex-encoded, 16-byte MD5 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.
The following example illustrates the format: bc:2a:72:af:fe:58:17:43:7a:5f:ba:5a:7c:90:f7:02
This property is read-only.
Data Type
String
signing_cert_fingerprint_sha1 property (C2PASigner Struct)
The hex-encoded, 20-byte SHA-1 fingerprint of the certificate.
Syntax
fn signing_cert_fingerprint_sha1(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
The hex-encoded, 20-byte SHA-1 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.
The following example illustrates the format: 30:7b:fa:38:65:83:ff:da:b4:4e:07:3f:17:b8:a4:ed:80:be:ff:84
This property is read-only.
Data Type
String
signing_cert_fingerprint_sha256 property (C2PASigner Struct)
The hex-encoded, 32-byte SHA-256 fingerprint of the certificate.
Syntax
fn signing_cert_fingerprint_sha256(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
The hex-encoded, 32-byte SHA-256 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.
The following example illustrates the format: 6a:80:5c:33:a9:43:ea:b0:96:12:8a:64:96:30:ef:4a:8a:96:86:ce:f4:c7:be:10:24:8e:2b:60:9e:f3:59:53
This property is read-only.
Data Type
String
signing_cert_issuer property (C2PASigner Struct)
The issuer of the certificate.
Syntax
fn signing_cert_issuer(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
The issuer of the certificate. This property contains a string representation of the name of the issuing authority for the certificate.
This property is read-only.
Data Type
String
signing_cert_private_key property (C2PASigner Struct)
The private key of the certificate (if available).
Syntax
fn signing_cert_private_key(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
The private key of the certificate (if available). The key is provided as PEM/Base64-encoded data.
NOTE: The signing_cert_private_key may be available but not exportable. In this case, signing_cert_private_key returns an empty string.
This property is read-only.
Data Type
String
signing_cert_private_key_available property (C2PASigner Struct)
Whether a PrivateKey is available for the selected certificate.
Syntax
fn signing_cert_private_key_available(&self) -> Result<bool, IPWorksLLMError>
Default Value
false
Remarks
Whether a signing_cert_private_key is available for the selected certificate. If signing_cert_private_key_available is True, the certificate may be used for authentication purposes (e.g., server authentication).
This property is read-only.
Data Type
bool
signing_cert_private_key_container property (C2PASigner Struct)
The name of the PrivateKey container for the certificate (if available).
Syntax
fn signing_cert_private_key_container(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
The name of the signing_cert_private_key container for the certificate (if available). This functionality is available only on Windows platforms.
This property is read-only.
Data Type
String
signing_cert_public_key property (C2PASigner Struct)
The public key of the certificate.
Syntax
fn signing_cert_public_key(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
The public key of the certificate. The key is provided as PEM/Base64-encoded data.
This property is read-only.
Data Type
String
signing_cert_public_key_algorithm property (C2PASigner Struct)
The textual description of the certificate's public key algorithm.
Syntax
fn signing_cert_public_key_algorithm(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
The textual description of the certificate's public key algorithm. The property contains either the name of the algorithm (e.g., "RSA" or "RSA_DH") or an object identifier (OID) string representing the algorithm.
This property is read-only.
Data Type
String
signing_cert_public_key_length property (C2PASigner Struct)
The length of the certificate's public key (in bits).
Syntax
fn signing_cert_public_key_length(&self) -> Result<i32, IPWorksLLMError>
Default Value
0
Remarks
The length of the certificate's public key (in bits). Common values are 512, 1024, and 2048.
This property is read-only.
Data Type
i32
signing_cert_serial_number property (C2PASigner Struct)
The serial number of the certificate encoded as a string.
Syntax
fn signing_cert_serial_number(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
The serial number of the certificate encoded as a string. The number is encoded as a series of hexadecimal digits, with each pair representing a byte of the serial number.
This property is read-only.
Data Type
String
signing_cert_signature_algorithm property (C2PASigner Struct)
The text description of the certificate's signature algorithm.
Syntax
fn signing_cert_signature_algorithm(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
The text description of the certificate's signature algorithm. The property contains either the name of the algorithm (e.g., "RSA" or "RSA_MD5RSA") or an object identifier (OID) string representing the algorithm.
This property is read-only.
Data Type
String
signing_cert_store property (C2PASigner Struct)
The name of the certificate store for the client certificate.
Syntax
fn signing_cert_store(&self) -> Result<Vec<u8>, IPWorksLLMError>
fn set_signing_cert_store(&self, value : Vec<u8>) -> Option<IPWorksLLMError> fn set_signing_cert_store_ref(&self, value : &[u8]) -> Option<IPWorksLLMError>
Default Value
"MY"
Remarks
The signing_cert_store_type property denotes the type of the certificate store specified by signing_cert_store. If the store is password-protected, specify the password in signing_cert_store_password.
signing_cert_store is used in conjunction with the signing_cert_subject property to specify client certificates. If signing_cert_store has a value, and signing_cert_subject or signing_cert_encoded is set, a search for a certificate is initiated. Please see the signing_cert_subject property for details.
Designations of certificate stores are platform dependent.
The following designations are the most common User and Machine certificate stores in Windows:
| MY | A certificate store holding personal certificates with their associated private keys. |
| CA | Certifying authority certificates. |
| ROOT | Root certificates. |
When the certificate store type is cstPFXFile, this property must be set to the name of the file. When the type is cstPFXBlob, the property must be set to the binary contents of a PFX file (i.e., PKCS#12 certificate store).
Data Type
Vec<u8>
signing_cert_store_password property (C2PASigner Struct)
If the type of certificate store requires a password, this property is used to specify the password needed to open the certificate store.
Syntax
fn signing_cert_store_password(&self) -> Result<String, IPWorksLLMError>
fn set_signing_cert_store_password(&self, value : &str) -> Option<IPWorksLLMError> fn set_signing_cert_store_password_ref(&self, value : &String) -> Option<IPWorksLLMError>
Default Value
""
Remarks
If the type of certificate store requires a password, this property is used to specify the password needed to open the certificate store.
Data Type
String
signing_cert_store_type property (C2PASigner Struct)
The type of certificate store for this certificate.
Syntax
fn signing_cert_store_type(&self) -> Result<i32, IPWorksLLMError>
fn set_signing_cert_store_type(&self, value : i32) -> Option<IPWorksLLMError>
Possible Values
0 // User
1 // Machine
2 // PFXFile
3 // PFXBlob
4 // JKSFile
5 // JKSBlob
6 // PEMKeyFile
7 // PEMKeyBlob
8 // PublicKeyFile
9 // PublicKeyBlob
10 // SSHPublicKeyBlob
11 // P7BFile
12 // P7BBlob
13 // SSHPublicKeyFile
14 // PPKFile
15 // PPKBlob
16 // XMLFile
17 // XMLBlob
18 // JWKFile
19 // JWKBlob
20 // SecurityKey
21 // BCFKSFile
22 // BCFKSBlob
23 // PKCS11
99 // Auto
Default Value
0
Remarks
The struct supports both public and private keys in a variety of formats. When the cstAuto value is used, the struct will automatically determine the type. This property can take one of the following values:
| 0 (cstUser - default) | For Windows, this specifies that the certificate store is a certificate store owned by the current user.
NOTE: This store type is not available in Java. |
| 1 (cstMachine) | For Windows, this specifies that the certificate store is a machine store.
NOTE: This store type is not available in Java. |
| 2 (cstPFXFile) | The certificate store is the name of a PFX (PKCS#12) file containing certificates. |
| 3 (cstPFXBlob) | The certificate store is a string (binary or Base64-encoded) representing a certificate store in PFX (PKCS#12) format. |
| 4 (cstJKSFile) | The certificate store is the name of a Java Key Store (JKS) file containing certificates.
NOTE: This store type is only available in Java. |
| 5 (cstJKSBlob) | The certificate store is a string (binary or Base64-encoded) representing a certificate store in Java Key Store (JKS) format.
NOTE: This store type is only available in Java. |
| 6 (cstPEMKeyFile) | The certificate store is the name of a PEM-encoded file that contains a private key and an optional certificate. |
| 7 (cstPEMKeyBlob) | The certificate store is a string (binary or Base64-encoded) that contains a private key and an optional certificate. |
| 8 (cstPublicKeyFile) | The certificate store is the name of a file that contains a PEM- or DER-encoded public key certificate. |
| 9 (cstPublicKeyBlob) | The certificate store is a string (binary or Base64-encoded) that contains a PEM- or DER-encoded public key certificate. |
| 10 (cstSSHPublicKeyBlob) | The certificate store is a string (binary or Base64-encoded) that contains an SSH-style public key. |
| 11 (cstP7BFile) | The certificate store is the name of a PKCS#7 file containing certificates. |
| 12 (cstP7BBlob) | The certificate store is a string (binary) representing a certificate store in PKCS#7 format. |
| 13 (cstSSHPublicKeyFile) | The certificate store is the name of a file that contains an SSH-style public key. |
| 14 (cstPPKFile) | The certificate store is the name of a file that contains a PPK (PuTTY Private Key). |
| 15 (cstPPKBlob) | The certificate store is a string (binary) that contains a PPK (PuTTY Private Key). |
| 16 (cstXMLFile) | The certificate store is the name of a file that contains a certificate in XML format. |
| 17 (cstXMLBlob) | The certificate store is a string that contains a certificate in XML format. |
| 18 (cstJWKFile) | The certificate store is the name of a file that contains a JWK (JSON Web Key). |
| 19 (cstJWKBlob) | The certificate store is a string that contains a JWK (JSON Web Key). |
| 21 (cstBCFKSFile) | The certificate store is the name of a file that contains a BCFKS (Bouncy Castle FIPS Key Store).
NOTE: This store type is only available in Java and .NET. |
| 22 (cstBCFKSBlob) | The certificate store is a string (binary or Base64-encoded) representing a certificate store in BCFKS (Bouncy Castle FIPS Key Store) format.
NOTE: This store type is only available in Java and .NET. |
| 23 (cstPKCS11) | The certificate is present on a physical security key accessible via a PKCS#11 interface.
To use a security key, create a new Certificate object and pass cstPKCS11 as the signing_cert_store_type, the full path of the PKCS#11 DLL as the signing_cert_store, and the PIN as the signing_cert_store_password. Code Example. SSH Authentication with Security Key (without CertMgr):
Alternatively, collect the necessary data using the CertMgr struct by calling the list_store_certificates method after setting the corresponding properties accordingly. The certificate information returned in the on_cert_list event's CertEncoded parameter may be saved for later use. When using a certificate obtained with this approach, pass the previously saved security key information as the signing_cert_store and set signing_cert_store_password to the PIN. Code Example. SSH Authentication with Security Key (with CertMgr):
|
| 99 (cstAuto) | The store type is automatically detected from the input data. This setting may be used with both public and private keys and can detect any of the supported formats automatically. |
Data Type
i32
signing_cert_subject_alt_names property (C2PASigner Struct)
Comma-separated lists of alternative subject names for the certificate.
Syntax
fn signing_cert_subject_alt_names(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
Comma-separated lists of alternative subject names for the certificate.
This property is read-only.
Data Type
String
signing_cert_thumbprint_md5 property (C2PASigner Struct)
The MD5 hash of the certificate.
Syntax
fn signing_cert_thumbprint_md5(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
The MD5 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.
This property is read-only.
Data Type
String
signing_cert_thumbprint_sha1 property (C2PASigner Struct)
The SHA-1 hash of the certificate.
Syntax
fn signing_cert_thumbprint_sha1(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
The SHA-1 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.
This property is read-only.
Data Type
String
signing_cert_thumbprint_sha256 property (C2PASigner Struct)
The SHA-256 hash of the certificate.
Syntax
fn signing_cert_thumbprint_sha256(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
The SHA-256 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.
This property is read-only.
Data Type
String
signing_cert_usage property (C2PASigner Struct)
The text description of UsageFlags .
Syntax
fn signing_cert_usage(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
This value will be one or more of the following strings and will be separated by commas:
- Digital Signature
- Non-Repudiation
- Key Encipherment
- Data Encipherment
- Key Agreement
- Certificate Signing
- CRL Signing
- Encipher Only
If the provider is OpenSSL, the value is a comma-separated list of X.509 certificate extension names.
This property is read-only.
Data Type
String
signing_cert_usage_flags property (C2PASigner Struct)
The flags that show intended use for the certificate.
Syntax
fn signing_cert_usage_flags(&self) -> Result<i32, IPWorksLLMError>
Default Value
0
Remarks
The flags that show intended use for the certificate. The value of signing_cert_usage_flags is a combination of the following flags:
| 0x80 | Digital Signature |
| 0x40 | Non-Repudiation |
| 0x20 | Key Encipherment |
| 0x10 | Data Encipherment |
| 0x08 | Key Agreement |
| 0x04 | Certificate Signing |
| 0x02 | CRL Signing |
| 0x01 | Encipher Only |
Please see the signing_cert_usage property for a text representation of signing_cert_usage_flags.
This functionality currently is not available when the provider is OpenSSL.
This property is read-only.
Data Type
i32
signing_cert_version property (C2PASigner Struct)
The certificate's version number.
Syntax
fn signing_cert_version(&self) -> Result<String, IPWorksLLMError>
Default Value
""
Remarks
The certificate's version number. The possible values are the strings "V1", "V2", and "V3".
This property is read-only.
Data Type
String
signing_cert_subject property (C2PASigner Struct)
The subject of the certificate used for client authentication.
Syntax
fn signing_cert_subject(&self) -> Result<String, IPWorksLLMError>
fn set_signing_cert_subject(&self, value : &str) -> Option<IPWorksLLMError> fn set_signing_cert_subject_ref(&self, value : &String) -> Option<IPWorksLLMError>
Default Value
""
Remarks
This property must be set after all other certificate properties are set. When this property is set, a search is performed in the current certificate store to locate a certificate with a matching subject.
If a matching certificate is found, the property is set to the full subject of the matching certificate.
If an exact match is not found, the store is searched for subjects containing the value of the property.
If a match is still not found, the property is set to an empty string, and no certificate is selected.
The special value "*" picks a random certificate in the certificate store.
The certificate subject is a comma-separated list of distinguished name fields and values. For instance, "CN=www.server.com, OU=test, C=US, E=example@email.com". Common fields and their meanings are as follows:
| Field | Meaning |
| CN | Common Name. This is commonly a hostname like www.server.com. |
| O | Organization |
| OU | Organizational Unit |
| L | Locality |
| S | State |
| C | Country |
| E | Email Address |
If a field value contains a comma, it must be quoted.
Data Type
String
signing_cert_encoded property (C2PASigner Struct)
The certificate (PEM/Base64 encoded).
Syntax
fn signing_cert_encoded(&self) -> Result<Vec<u8>, IPWorksLLMError>
fn set_signing_cert_encoded(&self, value : Vec<u8>) -> Option<IPWorksLLMError> fn set_signing_cert_encoded_ref(&self, value : &[u8]) -> Option<IPWorksLLMError>
Default Value
""
Remarks
The certificate (PEM/Base64 encoded). This property is used to assign a specific certificate. The signing_cert_store and signing_cert_subject properties also may be used to specify a certificate.
When signing_cert_encoded is set, a search is initiated in the current signing_cert_store for the private key of the certificate. If the key is found, signing_cert_subject is updated to reflect the full subject of the selected certificate; otherwise, signing_cert_subject is set to an empty string.
Data Type
Vec<u8>
tsaurl property (C2PASigner Struct)
The address of an RFC 3161 Time Stamping Authority.
Syntax
fn tsaurl(&self) -> Result<String, IPWorksLLMError>
fn set_tsaurl(&self, value : &str) -> Option<IPWorksLLMError> fn set_tsaurl_ref(&self, value : &String) -> Option<IPWorksLLMError>
Default Value
""
Remarks
This property specifies the Time Stamping Authority contacted during signing. When it is set, the struct obtains a trusted time-stamp over the signature and embeds it in the C2PA Manifest as a countersignature.
A time-stamped signature stays verifiable after the signing certificate expires, because a validator can establish that the signature existed while the certificate was still valid. The C2PA specification recommends obtaining a time-stamp whenever a TSA can be reached at signing time.
When this property is empty, no time-stamp is requested.
When it is set and the authority cannot be reached, or returns no token, signing fails rather than producing an untimestamped Manifest. Asking for a time-stamp and quietly getting none would leave a signature that looks complete but loses its meaning the day the certificate expires.
The connection to the authority is authenticated like any other: a TSA presenting an untrusted or expired certificate is refused. There is no event for overriding that decision.
Data Type
String
add_action method (C2PASigner Struct)
Records an action in the C2PA Manifest.
Syntax
fn add_action(&self, action : &str, digital_source_type : &str, software_agent : &str) -> Result<(), IPWorksLLMError>
Remarks
This method appends an action to the manifest's actions assertion, creating that assertion if it does not exist yet.
Action is the C2PA action identifier, such as c2pa.created, c2pa.edited, c2pa.opened, or c2pa.placed.
DigitalSourceType describes the nature of the content the action produced. The C2PA specification requires that a digital source type accompany the c2pa.created action for every asset. Commonly used values are:
| http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia | Media produced by a generative model. |
| http://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture | Captured by a camera or other recording device. |
| http://c2pa.org/digitalsourcetype/empty | The asset began as a new file with no digital content. |
Other values defined by the IPTC digital source type vocabulary may also be used. Pass an empty string when the action does not take one; a c2pa.opened action, for example, requires none.
SoftwareAgent names the tool that performed the action.
Disclosing AI-generated content is a single call:
signer.AddAction("c2pa.created",
"http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia",
"MyApp/1.0");
add_assertion method (C2PASigner Struct)
Appends an assertion to the Assertions collection.
Syntax
fn add_assertion(&self, assertion_label : &str, media_type : &str, data : &[u8]) -> Result<(), IPWorksLLMError>
Remarks
This method appends a new C2PAAssertion item to the assertions properties.
AssertionLabel is the C2PA assertion label, such as stds.schema-org.CreativeWork or stds.exif. MediaType is the payload's media type, normally application/json or application/cbor. Data is the assertion payload.
Passing the payload through verbatim keeps the API stable as the C2PA standard assertion set evolves: a new assertion type can be written without waiting for a new build of the struct.
string creativeWork = "{\"@context\":\"https://schema.org\",\"@type\":\"CreativeWork\",\"author\":[{\"@type\":\"Person\",\"name\":\"Jane Doe\"}]}";
signer.AddAssertion("stds.schema-org.CreativeWork", "application/json",
System.Text.Encoding.UTF8.GetBytes(creativeWork));
Use add_action instead when recording an action, since it builds the correctly structured actions assertion for you.
add_ingredient method (C2PASigner Struct)
Records that an asset went into the one being signed.
Syntax
fn add_ingredient(&self, source_file : &str, title : &str, relationship : &str) -> Result<(), IPWorksLLMError>
Remarks
An ingredient is a source asset and the relationship it has to this one. Recording ingredients is what turns individual Manifests into a provenance chain: a consumer can follow an edited image back to the photograph it came from, and that one back to the camera that produced it.
SourceFile is the asset that went in. Title is a human-readable name for it; pass an empty string to omit it. Relationship is one of:
| parentOf | The asset this one was derived from. An edit of a photograph names the photograph as its parent. |
| componentOf | An asset included in this one. A photograph placed into a composite is a component of it. This is the default when an empty string is passed. |
| inputTo | An asset fed to a process that produced this one. A photograph used as a prompt for a generative model is an input to the result. |
When the source carries a C2PA Manifest of its own, that Manifest is copied into the Manifest being written and the ingredient points at it. The chain then travels with the file: a verifier can follow it without needing the original source asset.
When the source carries no Manifest, the ingredient still records what the source was. The chain stops there, which is the truth about that asset rather than something to conceal.
Call this before Sign. Ingredients are read back through the Ingredients collection.
Example. Recording that an edited image came from a signed original:
C2PASigner signer = new C2PASigner();
signer.InputFile = "edited.jpg";
signer.OutputFile = "edited-signed.jpg";
signer.SigningCert = new Certificate(CertStoreTypes.cstPFXFile, "signer.pfx", "password", "*");
signer.ClaimGenerator = "Acme Editor/3.0";
// The photograph this edit was made from. Its Manifest travels along.
signer.AddIngredient("original.jpg", "Original photograph", "parentOf");
signer.AddAction("c2pa.edited", "", "Acme Editor/3.0");
signer.Sign();
Example. Recording the sources of a generated image:
C2PASigner signer = new C2PASigner();
signer.InputFile = "generated.png";
signer.OutputFile = "generated-signed.png";
signer.SigningCert = cert;
signer.ClaimGenerator = "Acme Generator/1.0";
signer.AddIngredient("reference.jpg", "Reference image", "inputTo");
// Disclose that the output is generative.
signer.AddAction("c2pa.created",
"http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia",
"Acme Generator/1.0");
signer.Sign();
config method (C2PASigner Struct)
Sets or retrieves a configuration setting.
Syntax
fn config(&self, configuration_string : &str) -> Result<String, IPWorksLLMError>
Remarks
config is a generic method available in every struct. It is used to set and retrieve configuration settings for the struct.
These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the struct, access to these internal properties is provided through the config method.
To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).
To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.
reset method (C2PASigner Struct)
This method will reset the struct.
Syntax
fn reset(&self) -> Result<(), IPWorksLLMError>
Remarks
This method will reset the struct's properties to their default values.
sign method (C2PASigner Struct)
Builds, signs, and embeds a C2PA Manifest.
Syntax
fn sign(&self) -> Result<(), IPWorksLLMError>
Remarks
This method reads the asset named by input_file (or held in input_data), builds a C2PA Manifest from the assertions properties, signs the claim with signing_cert, embeds the manifest into the asset, and writes the result to output_file (or output_data).
The following example signs a JPEG and discloses that it was produced by a generative model.
C2PASigner signer = new C2PASigner();
signer.InputFile = "photo.jpg";
signer.OutputFile = "photo-signed.jpg";
signer.ClaimGenerator = "MyApp/1.0";
signer.SigningCert = new Certificate(CertStoreTypes.cstPFXFile, "signer.pfx", "password", "*");
signer.AddAction("c2pa.created",
"http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia",
"MyApp/1.0");
signer.Sign();
Signing is a two-pass operation. The manifest is embedded once at a reserved size so the final byte layout of the asset is known, the content binding hash is then computed over the asset outside the manifest's own bytes, and the real signature replaces the reservation. This is what allows the hash to cover an asset that contains the manifest.
An error is thrown when signing_cert has no private key, when signature_algorithm is incompatible with that key, or when the input asset is of a format the struct cannot embed into.
on_error event (C2PASigner Struct)
Fired when information is available about errors during data delivery.
Syntax
// C2PASignerErrorEventArgs carries the C2PASigner Error event's parameters.
pub struct C2PASignerErrorEventArgs {
fn error_code(&self) -> i32
fn description(&self) -> &String
}
// C2PASignerErrorEvent defines the signature of the C2PASigner Error event's handler function.
pub trait C2PASignerErrorEvent {
fn on_error(&self, sender : C2PASigner, e : &mut C2PASignerErrorEventArgs);
}
impl <'a> C2PASigner<'a> {
pub fn on_error(&self) -> &'a dyn C2PASignerErrorEvent;
pub fn set_on_error(&mut self, value : &'a dyn C2PASignerErrorEvent);
...
}
Remarks
The on_error event is fired in case of exceptional conditions during message processing. Normally the struct fails with an error.
The error_code parameter contains an error code, and the description parameter contains a textual description of the error. For a list of valid error codes and their descriptions, please refer to the Error Codes section.
on_log event (C2PASigner Struct)
This event fires once for each log message.
Syntax
// C2PASignerLogEventArgs carries the C2PASigner Log event's parameters.
pub struct C2PASignerLogEventArgs {
fn log_level(&self) -> i32
fn message(&self) -> &String
fn log_type(&self) -> &String
}
// C2PASignerLogEvent defines the signature of the C2PASigner Log event's handler function.
pub trait C2PASignerLogEvent {
fn on_log(&self, sender : C2PASigner, e : &mut C2PASignerLogEventArgs);
}
impl <'a> C2PASigner<'a> {
pub fn on_log(&self) -> &'a dyn C2PASignerLogEvent;
pub fn set_on_log(&mut self, value : &'a dyn C2PASignerLogEvent);
...
}
Remarks
This event fires once for each log message generated by the struct. The verbosity is controlled by the LogLevel setting.
log_level indicates the level of message. Possible values are as follows:
| 0 (None) | No messages are logged. |
| 1 (Info - default) | Informational events such as the start and completion of a signing or verification operation are logged. |
| 2 (Verbose) | Detailed data such as individual manifest boxes and validation steps are logged. |
| 3 (Debug) | Debug data including byte offsets and hash inputs are logged. |
message is the log entry.
log_type identifies the type of log entry. Possible values are Info, Manifest, Signature, and Validation.
Config Settings (C2PASigner Struct)
The struct accepts one or more of the following configuration settings. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the struct, access to these internal properties is provided through the config method.C2PASigner Config Settings
Signing happens in two passes: the manifest is written once at a fixed size to establish the byte offsets the content binding needs, then rewritten with the real signature in the space reserved for it. If the signature does not fit, the whole operation repeats with a larger reservation, which costs time.
The default is 25600 bytes, the size the C2PA specification recommends. Lower it when the signing certificate chain is small and manifest size matters; raise it when signing with a long chain, to avoid the retry.
Base Config Settings
The following is a list of valid code page identifiers:
| Identifier | Name |
| 037 | IBM EBCDIC - U.S./Canada |
| 437 | OEM - United States |
| 500 | IBM EBCDIC - International |
| 708 | Arabic - ASMO 708 |
| 709 | Arabic - ASMO 449+, BCON V4 |
| 710 | Arabic - Transparent Arabic |
| 720 | Arabic - Transparent ASMO |
| 737 | OEM - Greek (formerly 437G) |
| 775 | OEM - Baltic |
| 850 | OEM - Multilingual Latin I |
| 852 | OEM - Latin II |
| 855 | OEM - Cyrillic (primarily Russian) |
| 857 | OEM - Turkish |
| 858 | OEM - Multilingual Latin I + Euro symbol |
| 860 | OEM - Portuguese |
| 861 | OEM - Icelandic |
| 862 | OEM - Hebrew |
| 863 | OEM - Canadian-French |
| 864 | OEM - Arabic |
| 865 | OEM - Nordic |
| 866 | OEM - Russian |
| 869 | OEM - Modern Greek |
| 870 | IBM EBCDIC - Multilingual/ROECE (Latin-2) |
| 874 | ANSI/OEM - Thai (same as 28605, ISO 8859-15) |
| 875 | IBM EBCDIC - Modern Greek |
| 932 | ANSI/OEM - Japanese, Shift-JIS |
| 936 | ANSI/OEM - Simplified Chinese (PRC, Singapore) |
| 949 | ANSI/OEM - Korean (Unified Hangul Code) |
| 950 | ANSI/OEM - Traditional Chinese (Taiwan; Hong Kong SAR, PRC) |
| 1026 | IBM EBCDIC - Turkish (Latin-5) |
| 1047 | IBM EBCDIC - Latin 1/Open System |
| 1140 | IBM EBCDIC - U.S./Canada (037 + Euro symbol) |
| 1141 | IBM EBCDIC - Germany (20273 + Euro symbol) |
| 1142 | IBM EBCDIC - Denmark/Norway (20277 + Euro symbol) |
| 1143 | IBM EBCDIC - Finland/Sweden (20278 + Euro symbol) |
| 1144 | IBM EBCDIC - Italy (20280 + Euro symbol) |
| 1145 | IBM EBCDIC - Latin America/Spain (20284 + Euro symbol) |
| 1146 | IBM EBCDIC - United Kingdom (20285 + Euro symbol) |
| 1147 | IBM EBCDIC - France (20297 + Euro symbol) |
| 1148 | IBM EBCDIC - International (500 + Euro symbol) |
| 1149 | IBM EBCDIC - Icelandic (20871 + Euro symbol) |
| 1200 | Unicode UCS-2 Little-Endian (BMP of ISO 10646) |
| 1201 | Unicode UCS-2 Big-Endian |
| 1250 | ANSI - Central European |
| 1251 | ANSI - Cyrillic |
| 1252 | ANSI - Latin I |
| 1253 | ANSI - Greek |
| 1254 | ANSI - Turkish |
| 1255 | ANSI - Hebrew |
| 1256 | ANSI - Arabic |
| 1257 | ANSI - Baltic |
| 1258 | ANSI/OEM - Vietnamese |
| 1361 | Korean (Johab) |
| 10000 | MAC - Roman |
| 10001 | MAC - Japanese |
| 10002 | MAC - Traditional Chinese (Big5) |
| 10003 | MAC - Korean |
| 10004 | MAC - Arabic |
| 10005 | MAC - Hebrew |
| 10006 | MAC - Greek I |
| 10007 | MAC - Cyrillic |
| 10008 | MAC - Simplified Chinese (GB 2312) |
| 10010 | MAC - Romania |
| 10017 | MAC - Ukraine |
| 10021 | MAC - Thai |
| 10029 | MAC - Latin II |
| 10079 | MAC - Icelandic |
| 10081 | MAC - Turkish |
| 10082 | MAC - Croatia |
| 12000 | Unicode UCS-4 Little-Endian |
| 12001 | Unicode UCS-4 Big-Endian |
| 20000 | CNS - Taiwan |
| 20001 | TCA - Taiwan |
| 20002 | Eten - Taiwan |
| 20003 | IBM5550 - Taiwan |
| 20004 | TeleText - Taiwan |
| 20005 | Wang - Taiwan |
| 20105 | IA5 IRV International Alphabet No. 5 (7-bit) |
| 20106 | IA5 German (7-bit) |
| 20107 | IA5 Swedish (7-bit) |
| 20108 | IA5 Norwegian (7-bit) |
| 20127 | US-ASCII (7-bit) |
| 20261 | T.61 |
| 20269 | ISO 6937 Non-Spacing Accent |
| 20273 | IBM EBCDIC - Germany |
| 20277 | IBM EBCDIC - Denmark/Norway |
| 20278 | IBM EBCDIC - Finland/Sweden |
| 20280 | IBM EBCDIC - Italy |
| 20284 | IBM EBCDIC - Latin America/Spain |
| 20285 | IBM EBCDIC - United Kingdom |
| 20290 | IBM EBCDIC - Japanese Katakana Extended |
| 20297 | IBM EBCDIC - France |
| 20420 | IBM EBCDIC - Arabic |
| 20423 | IBM EBCDIC - Greek |
| 20424 | IBM EBCDIC - Hebrew |
| 20833 | IBM EBCDIC - Korean Extended |
| 20838 | IBM EBCDIC - Thai |
| 20866 | Russian - KOI8-R |
| 20871 | IBM EBCDIC - Icelandic |
| 20880 | IBM EBCDIC - Cyrillic (Russian) |
| 20905 | IBM EBCDIC - Turkish |
| 20924 | IBM EBCDIC - Latin-1/Open System (1047 + Euro symbol) |
| 20932 | JIS X 0208-1990 & 0121-1990 |
| 20936 | Simplified Chinese (GB2312) |
| 21025 | IBM EBCDIC - Cyrillic (Serbian, Bulgarian) |
| 21027 | Extended Alpha Lowercase |
| 21866 | Ukrainian (KOI8-U) |
| 28591 | ISO 8859-1 Latin I |
| 28592 | ISO 8859-2 Central Europe |
| 28593 | ISO 8859-3 Latin 3 |
| 28594 | ISO 8859-4 Baltic |
| 28595 | ISO 8859-5 Cyrillic |
| 28596 | ISO 8859-6 Arabic |
| 28597 | ISO 8859-7 Greek |
| 28598 | ISO 8859-8 Hebrew |
| 28599 | ISO 8859-9 Latin 5 |
| 28605 | ISO 8859-15 Latin 9 |
| 29001 | Europa 3 |
| 38598 | ISO 8859-8 Hebrew |
| 50220 | ISO 2022 Japanese with no halfwidth Katakana |
| 50221 | ISO 2022 Japanese with halfwidth Katakana |
| 50222 | ISO 2022 Japanese JIS X 0201-1989 |
| 50225 | ISO 2022 Korean |
| 50227 | ISO 2022 Simplified Chinese |
| 50229 | ISO 2022 Traditional Chinese |
| 50930 | Japanese (Katakana) Extended |
| 50931 | US/Canada and Japanese |
| 50933 | Korean Extended and Korean |
| 50935 | Simplified Chinese Extended and Simplified Chinese |
| 50936 | Simplified Chinese |
| 50937 | US/Canada and Traditional Chinese |
| 50939 | Japanese (Latin) Extended and Japanese |
| 51932 | EUC - Japanese |
| 51936 | EUC - Simplified Chinese |
| 51949 | EUC - Korean |
| 51950 | EUC - Traditional Chinese |
| 52936 | HZ-GB2312 Simplified Chinese |
| 54936 | Windows XP: GB18030 Simplified Chinese (4 Byte) |
| 57002 | ISCII Devanagari |
| 57003 | ISCII Bengali |
| 57004 | ISCII Tamil |
| 57005 | ISCII Telugu |
| 57006 | ISCII Assamese |
| 57007 | ISCII Oriya |
| 57008 | ISCII Kannada |
| 57009 | ISCII Malayalam |
| 57010 | ISCII Gujarati |
| 57011 | ISCII Punjabi |
| 65000 | Unicode UTF-7 |
| 65001 | Unicode UTF-8 |
| Identifier | Name |
| 1 | ASCII |
| 2 | NEXTSTEP |
| 3 | JapaneseEUC |
| 4 | UTF8 |
| 5 | ISOLatin1 |
| 6 | Symbol |
| 7 | NonLossyASCII |
| 8 | ShiftJIS |
| 9 | ISOLatin2 |
| 10 | Unicode |
| 11 | WindowsCP1251 |
| 12 | WindowsCP1252 |
| 13 | WindowsCP1253 |
| 14 | WindowsCP1254 |
| 15 | WindowsCP1250 |
| 21 | ISO2022JP |
| 30 | MacOSRoman |
| 10 | UTF16String |
| 0x90000100 | UTF16BigEndian |
| 0x94000100 | UTF16LittleEndian |
| 0x8c000100 | UTF32String |
| 0x98000100 | UTF32BigEndian |
| 0x9c000100 | UTF32LittleEndian |
| 65536 | Proprietary |
- Product: The product the license is for.
- Product Key: The key the license was generated from.
- License Source: Where the license was found (e.g., RuntimeLicense, License File).
- License Type: The type of license installed (e.g., Royalty Free, Single Server).
- Last Valid Build: The last valid build number for which the license will work.
Setting this configuration setting to true tells the struct to use the internal implementation instead of using the system security libraries.
On Windows, this setting is set to false by default. On Linux/macOS, this setting is set to true by default.
To use the system security libraries for Linux, OpenSSL support must be enabled. For more information on how to enable OpenSSL, please refer to the OpenSSL Notes section.
Trappable Errors (C2PASigner Struct)
C2PASigner Errors
| 101 | Unsupported algorithm. See SignatureAlgorithm for the permitted signature algorithms, and the HashAlgorithm configuration setting for the permitted hash algorithms. |
| 102 | The signing certificate is missing or has no associated private key. |
| 103 | Unsupported asset format. The asset is not one of the formats the component can embed a C2PA Manifest into. |
| 105 | The claim signature could not be fitted into the reserved space. Raise the SignaturePadding configuration setting; the usual cause is an unusually large certificate chain. |
| 106 | A required parameter is missing or invalid. |
| 107 | The Manifest could not be laid out. This indicates a defect in the component rather than a problem with the input. |
| 108 | The Time Stamping Authority named by TSAURL did not return a time-stamp token. The Manifest is not written, so that a signature is never produced without the time-stamp that was asked for. |
| 109 | The output file already exists and Overwrite is False. |
| 304 | Cannot write file. |
| 305 | Cannot read file. |