KLVEObject Class Reference

KLVEObject class. More...

#include <crypto.h>

Inheritance diagram for KLVEObject:

KLVObject RefCount IRefCount List of all members.

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.
UUIDPtrGetContextID (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.

Detailed Description

KLVEObject class.

This class gives access to single AS-DCP encrypted KLV items within an MXF file with KLVObject interfacing


Member Enumeration Documentation

anonymous enum [protected]

The AS-DCP encryption system adds 32 bytes to the start of the encrypted data.

Enumerator:
EncryptionOverhead 

anonymous enum [protected]

The AS-DCP encryption system forces all encrypted data to be in multiples of 16 bytes.

Enumerator:
EncryptionGranularity 


Constructor & Destructor Documentation

KLVEObject ( ULPtr  ObjectUL  ) 

Construct a new KLVEObject.

KLVEObject ( KLVObjectPtr Object  ) 

Construct a KLVEObject linked to an encrypted KLVObject.

virtual ~KLVEObject (  )  [inline, virtual]


Member Function Documentation

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.

Returns:
False if Initialization Vector is rejected

bool SetDecryptIV ( size_t  IVSize,
const UInt8 IV,
bool  Force = false 
) [virtual]

Set a decryption Initialization Vector.

Returns:
False if Initialization Vector is rejected

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 ULPtr GetUL ( void   )  [inline, virtual]

Get the object's UL.

Reimplemented from KLVObject.

virtual void SetUL ( ULPtr  NewUL  )  [inline, virtual]

Set the object's UL.

Reimplemented from KLVObject.

Int32 GetKLSize ( void   )  [virtual]

Get the size of the key and length (not of the value).

Note:
For an KLVEObject this actually returns the sum of the size of all parts of the KLV other than the decrypted value - in other words total KLVE length - Source Length

Reimplemented from KLVObject.

GCElementKind GetGCElementKind ( void   )  [virtual]

Get a GCElementKind structure.

Reimplemented from KLVObject.

UInt32 GetGCTrackNumber ( void   )  [virtual]

Get the track number of this KLVObject (if it is a GC KLV, else 0).

Reimplemented from KLVObject.

std::string GetSource ( void   )  [virtual]

Get text that describes where this item came from.

Reimplemented from KLVObject.

Int32 ReadKL ( void   )  [virtual]

Read the key and length for this KLVObject from the current source.

Returns:
The number of bytes read (i.e. KLSize)

Reimplemented from KLVObject.

virtual size_t ReadData ( size_t  Size = static_cast<size_t>(-1)  )  [inline, virtual]

Read data from the start of the KLV value into the current DataChunk.

Parameters:
Size Number of bytes to read, if -1 all available bytes will be read (which could be billions!)
Returns:
The number of bytes read

Reimplemented from KLVObject.

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.

Parameters:
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!)
Returns:
The number of bytes read

Reimplemented from KLVObject.

Int32 WriteKL ( Int32  LenSize = 0  )  [virtual]

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!)

Note:
If the length will not fit in KLSize then KLSize will be updated

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.

Parameters:
Size The number of bytes to write, if -1 all available bytes will be written
Returns:
The number of bytes 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.

Parameters:
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
Returns:
The number of bytes 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.

Parameters:
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
Returns:
The number of bytes 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.

Parameters:
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
Returns:
The number of bytes written

Reimplemented from KLVObject.

size_t WriteDataTo ( const UInt8 Buffer,
Position  Offset,
size_t  Size 
) [virtual]

Write data from a given buffer to a given location in the destination file.

Parameters:
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
Returns:
The number of bytes written
Note:
As there may be a need for the implementation to know where within the value field this data lives, there is no WriteData(Buffer, Size) function.

Reimplemented from KLVObject.

virtual Length GetLength ( void   )  [inline, virtual]

Get the length of the value field.

Reimplemented from KLVObject.

virtual void SetLength ( Length  NewLength  )  [inline, virtual]

Set the length of the value field.

Reimplemented from KLVObject.

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

Returns:
true if all loaded OK, false on error

bool ReadFooter ( void   )  [protected]

Read the AS-DCP footer (if any).

Returns:
false on error, else true

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).

Returns:
false on error, else true

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.

Parameters:
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!)
Returns:
The number of bytes read The IV must have already been set. Only encrypted parts of the value may be read using this function (i.e. Offset >= PlaintextOffset)

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.

Parameters:
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!)
Returns:
The number of bytes read The IV must have already been set, Size must be a multiple of 16 as must (Offset - PlaintextOffset). Only encrypted parts of the value may be read using this function (i.e. Offset >= PlaintextOffset)

size_t WriteCryptoDataTo ( const UInt8 Buffer,
Position  Offset,
size_t  Size 
) [protected]

Write encrypted data from a given buffer to a given location in the destination file.

Parameters:
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
Returns:
Size if all OK, else != Size. This may not equal the actual number of bytes written. The IV must have already been set. Only encrypted parts of the value may be written using this function (i.e. Offset >= PlaintextOffset)


Member Data Documentation

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.

UUIDPtr ContextID [protected]

The context ID used to link to encryption metadata.

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

ULPtr SourceKey [protected]

Key for the plaintext KLV.

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).

UInt8 IV[16] [protected]

The Initialization Vector for this KLVE.

UInt8 Check[16] [protected]

The check value for this KLVE.

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.


The documentation for this class was generated from the following files:
Generated on Mon Apr 2 15:20:57 2007 for MXFLib by  doxygen 1.5.1-p1