Documentation
¶
Overview ¶
Package format provides set of interfaces for SDK message format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BodyFrame ¶ added in v0.3.0
type BodyFrame interface {
Serializable
// IsFinal indicates true if the frame is final.
IsFinal() bool
// SequenceNumber returns the frame sequence number.
SequenceNumber() int
// IV returns the frame IV.
IV() []byte
// EncryptedContent returns the frame encrypted content.
EncryptedContent() []byte
// AuthenticationTag returns the frame authentication tag.
AuthenticationTag() []byte
}
BodyFrame contains information about the body frame.
type Deserializer ¶ added in v0.3.0
type Deserializer interface {
// DeserializeHeader deserializes a message header from a buffer.
// It takes a buffer and a maximum number of encrypted data keys as input.
// It returns a MessageHeader, MessageHeaderAuth, and an error if any.
DeserializeHeader(buf *bytes.Buffer, maxEncryptedDataKeys int) (MessageHeader, MessageHeaderAuth, error)
// DeserializeBody deserializes a message body from a buffer.
// It takes a buffer, an algorithm suite, and a frame length as input.
// It returns a MessageBody and an error if any.
DeserializeBody(buf *bytes.Buffer, alg *suite.AlgorithmSuite, frameLen int) (MessageBody, error)
// It takes a buffer and an algorithm suite as input.
// It returns a MessageFooter and an error if any.
DeserializeFooter(buf *bytes.Buffer, alg *suite.AlgorithmSuite) (MessageFooter, error)
}
Deserializer defines methods for deserializing encrypted message components.
type HeaderParams ¶ added in v0.3.0
type HeaderParams struct {
AlgorithmSuite *suite.AlgorithmSuite
MessageID []byte
EncryptionContext suite.EncryptionContext
EncryptedDataKeys []MessageEDK
ContentType suite.ContentType
FrameLength int
AlgorithmSuiteData []byte
}
HeaderParams contains the parameters to be used to create MessageHeader.
type MessageAAD ¶
type MessageAAD interface {
Serializable
// EncryptionContext returns the encryption context.
EncryptionContext() suite.EncryptionContext
}
MessageAAD contains information about the additional authenticated data.
type MessageBody ¶ added in v0.3.0
type MessageBody interface {
Serializable
// Frames returns the body frames.
Frames() []BodyFrame
// AddFrame adds new BodyFrame to the body.
AddFrame(final bool, seqNum int, IV []byte, contentLength int, ciphertext, authTag []byte) error
}
MessageBody contains information about the message body.
type MessageEDK ¶
type MessageEDK interface {
Serializable
// ProviderID returns the provider ID.
ProviderID() string
// ProviderInfo returns the provider info.
ProviderInfo() string
// EncryptedDataKey returns the encrypted data key.
EncryptedDataKey() []byte
}
MessageEDK contains information about the encrypted data key.
type MessageFooter ¶ added in v0.3.0
type MessageFooter interface {
Serializable
SignLen() int
Signature() []byte
}
MessageFooter contains information about the message footer.
type MessageHeader ¶
type MessageHeader interface {
Serializable
MessageHeaderBase
// Type returns the message type. Present only in V1.
Type() MessageType
// Reserved returns the reserved bytes. Present only in V1.
Reserved() []byte
// IVLength returns the length of the IV. Present only in V1.
IVLength() int
// AlgorithmSuiteData returns the algorithm suite data. Present only in V2.
AlgorithmSuiteData() []byte
}
MessageHeader contains information about the message header.
type MessageHeaderAuth ¶
type MessageHeaderAuth interface {
Serializable
// AuthData returns the authentication data.
AuthData() []byte
// IV returns the IV. Present only in V1.
IV() []byte
}
MessageHeaderAuth contains information about the message header authentication.
type MessageHeaderBase ¶ added in v0.4.0
type MessageHeaderBase interface {
// Version returns the message format version.
Version() suite.MessageFormatVersion
// AlgorithmSuite returns the algorithm suite used with the message.
AlgorithmSuite() *suite.AlgorithmSuite
// MessageID returns the message ID.
MessageID() []byte
// AADLength returns the length of the additional authenticated data.
AADLength() int
// AADData returns the additional authenticated data.
AADData() MessageAAD
// EncryptedDataKeyCount returns the number of encrypted data keys.
EncryptedDataKeyCount() int
// EncryptedDataKeys returns the encrypted data keys.
EncryptedDataKeys() []MessageEDK
// ContentType returns the content type.
ContentType() suite.ContentType
// FrameLength returns the frame length.
FrameLength() int
}
MessageHeaderBase is the common interface for the message header.
type MessageType ¶ added in v0.4.0
type MessageType int
MessageType is the type of the message. The type indicates the kind of structure. The only supported type is CustomerAEData.
const CustomerAEData MessageType = 128
CustomerAEData is a customer authenticated encrypted data. Its type value is 128, encoded as byte 80 in hexadecimal notation.
type Serializable ¶
type Serializable interface {
// Len returns the length of the serialized object.
Len() int
// Bytes returns the serialized object.
Bytes() []byte
}
Serializable is an interface for objects that can be serialized to bytes.
type Serializer ¶ added in v0.3.0
type Serializer interface {
// SerializeHeader serializes a message header.
// It takes header parameters as input and returns a MessageHeader and an error if any.
SerializeHeader(p HeaderParams) (MessageHeader, error)
// SerializeHeaderAuth serializes a message header authentication data.
// It takes a message format version, an initialization vector, and authentication data as input.
// It returns a MessageHeaderAuth and an error if any.
SerializeHeaderAuth(v suite.MessageFormatVersion, iv, authData []byte) (MessageHeaderAuth, error)
// SerializeBody serializes a message body.
// It takes an algorithm suite and a frame length as input.
// It returns a MessageBody and an error if any.
SerializeBody(alg *suite.AlgorithmSuite, frameLength int) (MessageBody, error)
// It takes an algorithm suite and a signature as input.
// It returns a MessageFooter and an error if any.
SerializeFooter(alg *suite.AlgorithmSuite, signature []byte) (MessageFooter, error)
}
Serializer defines methods for serializing encrypted message components.