#include <crypto.h>
Inheritance diagram for KLVEObject:
Public Member Functions | |
void | SetEncrypt (EncryptPtr NewWrapper) |
Set the encryption wrapper. | |
void | SetDecrypt (DecryptPtr NewWrapper) |
Set the decryption wrapper. | |
void | SetWriteHasher (HashPtr &Hasher) |
Set a hasher to use when writing. | |
void | SetReadHasher (HashPtr &Hasher) |
Set a hasher to use when reading. | |
virtual bool | SetEncryptIV (size_t IVSize, const UInt8 *IV, bool Force=false) |
Set an encryption Initialization Vector. | |
virtual bool | SetDecryptIV (size_t IVSize, const UInt8 *IV, bool Force=false) |
Set a decryption Initialization Vector. | |
virtual DataChunkPtr | GetEncryptIV (void) |
Get the Initialization Vector that will be used for the next encryption. | |
virtual DataChunkPtr | GetDecryptIV (void) |
Get the Initialization Vector that will be used for the next decryption. | |
void | SetPlaintextOffset (Length Offset) |
Set the plaintext offset to use when encrypting. | |
Length | GetPlaintextOffset (void) |
Get the plaintext offset of the encrypted data. | |
KLVEObject (ULPtr ObjectUL) | |
Construct a new KLVEObject. | |
KLVEObject (KLVObjectPtr &Object) | |
Construct a KLVEObject linked to an encrypted KLVObject. | |
virtual void | Init (void) |
Initialise the KLVEObject specifics after basic construction (and KLVObject::Init()). | |
virtual | ~KLVEObject () |
virtual ULPtr | GetUL (void) |
Get the object's UL. | |
virtual void | SetUL (ULPtr NewUL) |
Set the object's UL. | |
virtual Int32 | GetKLSize (void) |
Get the size of the key and length (not of the value). | |
virtual GCElementKind | GetGCElementKind (void) |
Get a GCElementKind structure. | |
virtual UInt32 | GetGCTrackNumber (void) |
Get the track number of this KLVObject (if it is a GC KLV, else 0). | |
virtual std::string | GetSource (void) |
Get text that describes where this item came from. | |
virtual Int32 | ReadKL (void) |
Read the key and length for this KLVObject from the current source. | |
virtual size_t | ReadData (size_t Size=static_cast< size_t >(-1)) |
Read data from the start of the KLV value into the current DataChunk. | |
virtual size_t | ReadDataFrom (Position Offset, size_t Size=static_cast< size_t >(-1)) |
Read data from a specified position in the KLV value field into the DataChunk. | |
virtual Int32 | WriteKL (Int32 LenSize=0) |
Write the key and length of the current DataChunk to the destination file. | |
virtual size_t | WriteData (size_t Size=static_cast< size_t >(-1)) |
Write (some of) the current data to the same location in the destination file. | |
virtual size_t | WriteDataFrom (Position Start, size_t Size=static_cast< size_t >(-1)) |
Write (some of) the current data to the same location in the destination file. | |
virtual size_t | WriteDataTo (Position Offset, size_t Size=static_cast< size_t >(-1)) |
Write (some of) the current data to a different location in the destination file. | |
virtual size_t | WriteDataFromTo (Position Offset, Position Start, size_t Size=static_cast< size_t >(-1)) |
Write (some of) the current data to the same location in the destination file. | |
virtual size_t | WriteDataTo (const UInt8 *Buffer, Position Offset, size_t Size) |
Write data from a given buffer to a given location in the destination file. | |
virtual Length | GetLength (void) |
Get the length of the value field. | |
virtual void | SetLength (Length NewLength) |
Set the length of the value field. | |
void | SetContextID (UUIDPtr &Context) |
Set the context ID. | |
UUIDPtr & | GetContextID (void) |
Get the context ID. | |
Protected Types | |
enum | { EncryptionOverhead = 32 } |
The AS-DCP encryption system adds 32 bytes to the start of the encrypted data. More... | |
enum | { EncryptionGranularity = 16 } |
The AS-DCP encryption system forces all encrypted data to be in multiples of 16 bytes. More... | |
Protected Member Functions | |
bool | LoadData (void) |
Load the AS-DCP set data. | |
bool | ReadFooter (void) |
Read the AS-DCP footer (if any). | |
UInt32 | CalcFooterLength (void) |
Calculate the size of the AS-DCP footer for this KLVEObject. | |
bool | WriteFooter (void) |
Write the AS-DCP footer (if fequired). | |
size_t | ReadCryptoDataFrom (Position Offset, size_t Size=static_cast< size_t >(-1)) |
Read data from a specified position in the encrypted portion of the KLV value field into the DataChunk. | |
size_t | ReadChunkedCryptoDataFrom (Position Offset, size_t Size) |
Read an integer set of chunks from a specified position in the encrypted portion of the KLV value field into the DataChunk. | |
size_t | WriteCryptoDataTo (const UInt8 *Buffer, Position Offset, size_t Size) |
Write encrypted data from a given buffer to a given location in the destination file. | |
Protected Attributes | |
EncryptPtr | Encrypt |
Pointer to the encryption wrapper. | |
DecryptPtr | Decrypt |
Pointer to the decryption wrapper. | |
HashPtr | WriteHasher |
Pointer to a hasher being used for hashing data being written. | |
HashPtr | ReadHasher |
Pointer to a hasher being used for hashing data being read. | |
bool | DataLoaded |
True once the AS-DCP header data has been read. | |
UUIDPtr | ContextID |
The context ID used to link to encryption metadata. | |
Length | PlaintextOffset |
Number of unencrypted bytes at start of source data. | |
ULPtr | SourceKey |
Key for the plaintext KLV. | |
Length | EncryptedLength |
Length of the encrypted KLV Value. | |
int | SourceLengthFormat |
Number of bytes used to encode SourceLength in the KLVE (allows us to faithfully recreate if required). | |
UInt8 | IV [16] |
The Initialization Vector for this KLVE. | |
UInt8 | Check [16] |
The check value for this KLVE. | |
UUIDPtr | TrackFileID |
The optional TrackFile ID or NULL. | |
UInt64 | SequenceNumber |
The optional Sequence Number of this KLVE within the TrackFile. | |
bool | HasSequenceNumber |
True if SequenceNumber has been set or read. | |
DataChunkPtr | MIC |
The optional MIC (if loaded or computed when reading or computed when writing) else NULL. | |
size_t | DataOffset |
Offset of the start of the encrypted value from the start of the KLV value. | |
DataChunkPtr | EncryptionIV |
Encryption IV if one has been specified. | |
Position | CurrentReadOffset |
The location of the next read (if reading in sequence) - used to detect random access attempts. | |
Position | CurrentWriteOffset |
The location of the next write (if writing in sequence) - used to detect random access attempts. | |
int | PreDecrypted |
Number of extra bytes decrypted last time that are buffer for the next read. | |
UInt8 | PreDecryptBuffer [EncryptionGranularity] |
Left over bytes from decrypting the last chunk - these will be returned first with the next read call. | |
int | AwaitingEncryption |
Number of left over bytes not encrypted last time that are buffer for the next write. | |
UInt8 | AwaitingEncryptionBuffer [EncryptionGranularity] |
Left over bytes from encrypting the last chunk - these will be written first at the next write call. | |
UInt32 | FooterLength |
The size of the AS-DCP footer to be written for this KLVEObject. |
This class gives access to single AS-DCP encrypted KLV items within an MXF file with KLVObject interfacing
anonymous enum [protected] |
anonymous enum [protected] |
KLVEObject | ( | ULPtr | ObjectUL | ) |
Construct a new KLVEObject.
KLVEObject | ( | KLVObjectPtr & | Object | ) |
Construct a KLVEObject linked to an encrypted KLVObject.
virtual ~KLVEObject | ( | ) | [inline, virtual] |
void SetEncrypt | ( | EncryptPtr | NewWrapper | ) | [inline] |
Set the encryption wrapper.
void SetDecrypt | ( | DecryptPtr | NewWrapper | ) | [inline] |
Set the decryption wrapper.
void SetWriteHasher | ( | HashPtr & | Hasher | ) | [inline] |
Set a hasher to use when writing.
The hasher must be initialized and ready to start hashing
void SetReadHasher | ( | HashPtr & | Hasher | ) | [inline] |
Set a hasher to use when reading.
The hasher must be initialized and ready to start hashing
virtual bool SetEncryptIV | ( | size_t | IVSize, | |
const UInt8 * | IV, | |||
bool | Force = false | |||
) | [inline, virtual] |
Set an encryption Initialization Vector.
bool SetDecryptIV | ( | size_t | IVSize, | |
const UInt8 * | IV, | |||
bool | Force = false | |||
) | [virtual] |
Set a decryption Initialization Vector.
DataChunkPtr GetEncryptIV | ( | void | ) | [virtual] |
Get the Initialization Vector that will be used for the next encryption.
DataChunkPtr GetDecryptIV | ( | void | ) | [virtual] |
Get the Initialization Vector that will be used for the next decryption.
void SetPlaintextOffset | ( | Length | Offset | ) | [inline] |
Set the plaintext offset to use when encrypting.
Length GetPlaintextOffset | ( | void | ) | [inline] |
Get the plaintext offset of the encrypted data.
void Init | ( | void | ) | [virtual] |
Initialise the KLVEObject specifics after basic construction (and KLVObject::Init()).
Reimplemented from KLVObject.
virtual void SetUL | ( | ULPtr | NewUL | ) | [inline, virtual] |
Int32 GetKLSize | ( | void | ) | [virtual] |
Get the size of the key and length (not of the value).
Reimplemented from KLVObject.
GCElementKind GetGCElementKind | ( | void | ) | [virtual] |
UInt32 GetGCTrackNumber | ( | void | ) | [virtual] |
std::string GetSource | ( | void | ) | [virtual] |
Int32 ReadKL | ( | void | ) | [virtual] |
virtual size_t ReadData | ( | size_t | Size = static_cast<size_t>(-1) |
) | [inline, virtual] |
size_t ReadDataFrom | ( | Position | Offset, | |
size_t | Size = static_cast< size_t >(-1) | |||
) | [virtual] |
Read data from a specified position in the KLV value field into the DataChunk.
Offset | Offset from the start of the KLV value from which to start reading | |
Size | Number of bytes to read, if -1 all available bytes will be read (which could be billions!) |
Reimplemented from KLVObject.
Write the key and length of the current DataChunk to the destination file.
The key and length will be written to the source file as set by SetSource. If LenSize is zero the length will be formatted to match KLSize (if possible!)
Write Out the Header
Reimplemented from KLVObject.
virtual size_t WriteData | ( | size_t | Size = static_cast<size_t>(-1) |
) | [inline, virtual] |
Write (some of) the current data to the same location in the destination file.
Size | The number of bytes to write, if -1 all available bytes will be written |
Reimplemented from KLVObject.
virtual size_t WriteDataFrom | ( | Position | Start, | |
size_t | Size = static_cast<size_t>(-1) | |||
) | [inline, virtual] |
Write (some of) the current data to the same location in the destination file.
Start | The offset within the current DataChunk of the first byte to write | |
Size | The number of bytes to write, if -1 all available bytes will be written |
Reimplemented from KLVObject.
virtual size_t WriteDataTo | ( | Position | Offset, | |
size_t | Size = static_cast<size_t>(-1) | |||
) | [inline, virtual] |
Write (some of) the current data to a different location in the destination file.
Offset | The offset within the KLV value field of the first byte to write | |
Size | The number of bytes to write, if -1 all available bytes will be written |
Reimplemented from KLVObject.
virtual size_t WriteDataFromTo | ( | Position | Offset, | |
Position | Start, | |||
size_t | Size = static_cast<size_t>(-1) | |||
) | [inline, virtual] |
Write (some of) the current data to the same location in the destination file.
Offset | The offset within the KLV value field of the first byte to write | |
Start | The offset within the current DataChunk of the first byte to write | |
Size | The number of bytes to write, if -1 all available bytes will be written |
Reimplemented from KLVObject.
Write data from a given buffer to a given location in the destination file.
Buffer | Pointer to data to be written | |
Offset | The offset within the KLV value field of the first byte to write | |
Size | The number of bytes to write |
Reimplemented from KLVObject.
virtual Length GetLength | ( | void | ) | [inline, virtual] |
virtual void SetLength | ( | Length | NewLength | ) | [inline, virtual] |
void SetContextID | ( | UUIDPtr & | Context | ) | [inline] |
Set the context ID.
UUIDPtr& GetContextID | ( | void | ) | [inline] |
Get the context ID.
bool LoadData | ( | void | ) | [protected] |
Load the AS-DCP set data.
Sets DataLoaded on success
bool ReadFooter | ( | void | ) | [protected] |
Read the AS-DCP footer (if any).
UInt32 CalcFooterLength | ( | void | ) | [protected] |
Calculate the size of the AS-DCP footer for this KLVEObject.
The size it returned and also written to property FooterLength
bool WriteFooter | ( | void | ) | [protected] |
Write the AS-DCP footer (if fequired).
size_t ReadCryptoDataFrom | ( | Position | Offset, | |
size_t | Size = static_cast< size_t >(-1) | |||
) | [protected] |
Read data from a specified position in the encrypted portion of the KLV value field into the DataChunk.
Offset | Offset from the start of the KLV value from which to start reading | |
Size | Number of bytes to read, if -1 all available bytes will be read (which could be billions!) |
size_t ReadChunkedCryptoDataFrom | ( | Position | Offset, | |
size_t | Size | |||
) | [protected] |
Read an integer set of chunks from a specified position in the encrypted portion of the KLV value field into the DataChunk.
Offset | Offset from the start of the KLV value from which to start reading | |
Size | Number of bytes to read, if -1 all available bytes will be read (which could be billions!) |
Write encrypted data from a given buffer to a given location in the destination file.
Buffer | Pointer to data to be written | |
Offset | The offset within the KLV value field of the first byte to write | |
Size | The number of bytes to write |
EncryptPtr Encrypt [protected] |
Pointer to the encryption wrapper.
DecryptPtr Decrypt [protected] |
Pointer to the decryption wrapper.
HashPtr WriteHasher [protected] |
Pointer to a hasher being used for hashing data being written.
HashPtr ReadHasher [protected] |
Pointer to a hasher being used for hashing data being read.
bool DataLoaded [protected] |
True once the AS-DCP header data has been read.
Length PlaintextOffset [protected] |
Number of unencrypted bytes at start of source data.
DRAGONS: ValueLength is a standard MXF length (signed 64-bit), however the AS-DCP spec uses an unsigned 64-bit for PlaintextOffset. We use a Length for PlaintextOffset to keep comparison signs the same
Length EncryptedLength [protected] |
Length of the encrypted KLV Value.
int SourceLengthFormat [protected] |
Number of bytes used to encode SourceLength in the KLVE (allows us to faithfully recreate if required).
UUIDPtr TrackFileID [protected] |
The optional TrackFile ID or NULL.
UInt64 SequenceNumber [protected] |
The optional Sequence Number of this KLVE within the TrackFile.
bool HasSequenceNumber [protected] |
True if SequenceNumber has been set or read.
DataChunkPtr MIC [protected] |
The optional MIC (if loaded or computed when reading or computed when writing) else NULL.
size_t DataOffset [protected] |
Offset of the start of the encrypted value from the start of the KLV value.
DataChunkPtr EncryptionIV [protected] |
Encryption IV if one has been specified.
Position CurrentReadOffset [protected] |
The location of the next read (if reading in sequence) - used to detect random access attempts.
Position CurrentWriteOffset [protected] |
The location of the next write (if writing in sequence) - used to detect random access attempts.
int PreDecrypted [protected] |
Number of extra bytes decrypted last time that are buffer for the next read.
UInt8 PreDecryptBuffer[EncryptionGranularity] [protected] |
Left over bytes from decrypting the last chunk - these will be returned first with the next read call.
int AwaitingEncryption [protected] |
Number of left over bytes not encrypted last time that are buffer for the next write.
UInt8 AwaitingEncryptionBuffer[EncryptionGranularity] [protected] |
Left over bytes from encrypting the last chunk - these will be written first at the next write call.
UInt32 FooterLength [protected] |
The size of the AS-DCP footer to be written for this KLVEObject.