Skip to content

Function: validateC2paInitSegment() ​

ts
function validateC2paInitSegment(bytes): Promise<InitSegmentValidation>;

Defined in: init/validateC2paInitSegment.ts:242

Validates a C2PA init segment: parses the manifest, extracts and verifies the certificate, validates the BMFF hard binding hash, verifies all session keys from the c2pa.session-keys assertion, and performs manifest integrity checks (assertion references and hashes, undeclared assertions, the hard binding count, duplicate manifest boxes, action ingredients, and claim signature verification).

Only session keys with a valid signer binding and an unexpired validity period are included in the result. The result holds sessionKeys and merkleMaps only when every manifest integrity check and every content hash check pass, so check isValid before you use either list.

The result includes LiveVideoStatusCode.SESSIONKEY_INVALID if the function finds an invalid session key (C2PA section 19.7.3). A session key is invalid if it does not conform to section 18.25.2, or if its signer binding fails verification. The function does not check every rule of section 18.25.2. An expired session key does not count as invalid. A c2pa.session-keys assertion without a session key, or with CBOR that does not decode, also causes SESSIONKEY_INVALID. An init segment without a c2pa.session-keys assertion does not cause SESSIONKEY_INVALID. In a section 19.4 stream, an empty sessionKeys list makes each VSI segment fail with SEGMENT_INVALID.

Parameters ​

bytes ​

Uint8Array

Raw init segment bytes

Returns ​

Promise<InitSegmentValidation>

Structured validation result. It has INIT_INVALID if the segment has an mdat box or no c2pa.hash.bmff.v3 assertion. It also has INIT_INVALID if the content hash does not include the moov box (C2PA section 19.2.3). A manifest without a hard binding assertion also has CLAIM_HARD_BINDINGS_MISSING. A content hash that does not match adds INIT_INVALID and ASSERTION_BMFFHASH_MISMATCH. A c2pa.hash.bmff.v3 assertion that does not conform to the bmff-hash-map adds ASSERTION_BMFFHASH_MALFORMED.

Throws ​

If no C2PA UUID box is found

Example ​

ts
it('throws for empty bytes (no C2PA UUID box)', async () => {
	await rejects(() => validateC2paInitSegment(new Uint8Array(0)), /No C2PA UUID box/)
})

A Streaming Video Technology Alliance project.