ecom.verification

Module Contents

Classes

MessageVerifier

A helper that can add data to verify the integrity of a message and use that data to verify a message.

exception ecom.verification.VerificationError[source]

Bases: RuntimeError

An error indicating that a message failed its verification check.

exception ecom.verification.MissingDataForVerificationError[source]

Bases: VerificationError

An error indicating that a message failed its verification check because some it is incomplete.

class ecom.verification.MessageVerifier[source]

Bases: abc.ABC

A helper that can add data to verify the integrity of a message and use that data to verify a message.

abstract verify(data: bytes, message: ecom.message.MessageType, header: ecom.datatypes.TypeInfo[ecom.datatypes.StructType], messageSize: int) Optional[bytes][source]

Verify the integrity of the message.

Raises:

VerificationError – if the message fails the verification check and the original data can’t be recovered.

Parameters:
  • data – The raw data of the message. May also include other trailing data.

  • message – The type of message.

  • header – The header type information of the message.

  • messageSize – The size of the message, as calculated with the unverified data.

Returns:

None if the message was verified successfully or the bytes of the error corrected message and any bytes from the given data that were not part of the message.

abstract addVerificationData(data: bytes, message: ecom.message.MessageType, header: ecom.datatypes.TypeInfo[ecom.datatypes.StructType]) bytes[source]

Add extra verification data to a message.

Parameters:
  • data – The message data.

  • message – The type of message.

  • header – The header type information of the message.

Returns:

The message with verification data.

abstract addPlaceholderVerificationData(data: Dict[str, Any])[source]

When constructing a message, this allows to add a placeholder value to the header that will be filled later by addVerificationData.

Parameters:

data – A dictionary to store the placeholder verification data to.