Documentation
¶
Index ¶
- Constants
- func DigestContents(c []byte) string
- type Fingerprint
- type Message
- func (m Message) ContentsSize() int
- func (m Message) Copy() Message
- func (m Message) Digest() string
- func (m Message) GetContents() []byte
- func (m Message) GetEphemeralRID() []byte
- func (m Message) GetKeyFP() Fingerprint
- func (m Message) GetMac() []byte
- func (m Message) GetPayloadA() []byte
- func (m Message) GetPayloadB() []byte
- func (m Message) GetPrimeByteLen() int
- func (m Message) GetRawContents() []byte
- func (m Message) GetRawContentsSize() int
- func (m Message) GetSIH() []byte
- func (m Message) GoString() string
- func (m *Message) Marshal() []byte
- func (m *Message) MarshalImmutable() []byte
- func (m Message) SetContents(c []byte)
- func (m Message) SetEphemeralRID(ephemeralRID []byte)
- func (m Message) SetGroupBits(bitA, bitB bool)
- func (m Message) SetKeyFP(fp Fingerprint)
- func (m Message) SetMac(mac []byte)
- func (m Message) SetPayloadA(payload []byte)
- func (m Message) SetPayloadB(payload []byte)
- func (m Message) SetRawContents(c []byte)
- func (m Message) SetSIH(identityFP []byte)
- func (m *Message) Version() uint8
Constants ¶
const ( KeyFPLen = 32 MacLen = 32 EphemeralRIDLen = 8 SIHLen = 25 RecipientIDLen = EphemeralRIDLen + SIHLen MinimumPrimeSize = 2*MacLen + RecipientIDLen AssociatedDataSize = KeyFPLen + MacLen + RecipientIDLen )
Variables ¶
This section is empty.
Functions ¶
func DigestContents ¶
DigestContents - message.Digest that works without the message format
Types ¶
type Fingerprint ¶
func NewFingerprint ¶
func NewFingerprint(b []byte) Fingerprint
NewFingerprint generates a new Fingerprint with the provided bytes.
func (Fingerprint) Bytes ¶
func (fp Fingerprint) Bytes() []byte
Bytes returns the fingerprint as a byte slice.
func (Fingerprint) MarshalJSON ¶
func (fp Fingerprint) MarshalJSON() ([]byte, error)
MarshalJSON adheres to the json.Marshaler interface.
func (Fingerprint) String ¶
func (fp Fingerprint) String() string
String returns the fingerprint as a base 64 encoded string. This functions satisfies the fmt.Stringer interface.
func (*Fingerprint) UnmarshalJSON ¶
func (fp *Fingerprint) UnmarshalJSON(data []byte) error
UnmarshalJSON adheres to the json.Unmarshaler interface.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message structure stores all the data serially. Subsequent fields point to subsections of the serialised data.
func NewMessage ¶
NewMessage creates a new empty message based upon the size of the encryption primes. All subcomponents point to locations in the internal data buffer. Panics if the prime size to too small.
func (Message) ContentsSize ¶
ContentsSize returns the maximum size of the contents.
func (Message) GetContents ¶
GetContents returns the exact contents of the message. This size of the return is based on the size of the contents actually stored.
func (Message) GetEphemeralRID ¶
GetEphemeralRID returns the ephemeral recipient ID.
func (Message) GetKeyFP ¶
func (m Message) GetKeyFP() Fingerprint
GetKeyFP gets the key Fingerprint flips the first bit to 0 on return
func (Message) GetPayloadA ¶
GetPayloadA returns payload A, which is the first half of the message.
func (Message) GetPayloadB ¶
GetPayloadB returns payload B, which is the last half of the message.
func (Message) GetPrimeByteLen ¶
GetPrimeByteLen returns the size of the prime used.
func (Message) GetRawContents ¶
GetRawContents returns the exact contents of the message. This field crosses over the group barrier and the setter of this is responsible for ensuring the underlying payloads are within the group. flips the first bit to 0 on return
func (Message) GetRawContentsSize ¶
GetRawContentsSize returns the exact contents of the message.
func (Message) GoString ¶
GoString returns the Message key fingerprint, MAC, ephemeral recipient ID, identity fingerprint, and contents as a string. This functions satisfies the fmt.GoStringer interface.
func (*Message) Marshal ¶
Marshal marshals the message into a byte slice. Use this when sending over the wire or other socket connection. Do not use this if you ever want to compare a marshalled message with itself, because both the Ephemeral ID and SIH are modified on each send attempt.
func (*Message) MarshalImmutable ¶
MarshalImmutable marshals the message into a byte slice. Note that the Ephemeral ID and the SIH both change every time a message is sent. This function 0's those fields to guarantee that the same message will be byte identical with itself when Marshalled.
func (Message) SetContents ¶
SetContents sets the contents of the message. This overwrites any storage already in the message but will not clear bits beyond the size of the passed contents. Panics if the passed contents is larger than the maximum contents size.
func (Message) SetEphemeralRID ¶
SetEphemeralRID copies the ephemeral recipient ID bytes into the message.
func (Message) SetGroupBits ¶
SetGroupBits allows the first and second bits to be set in the payload. This should be used with code which determines if the bit can be set to 1 before proceeding.
func (Message) SetKeyFP ¶
func (m Message) SetKeyFP(fp Fingerprint)
SetKeyFP sets the key Fingerprint. Checks that the first bit of the Key Fingerprint is 0, otherwise it panics.
func (Message) SetMac ¶
SetMac sets the MAC. Checks that the first bit of the MAC is 0, otherwise it panics.
func (Message) SetPayloadA ¶
SetPayloadA copies the passed byte slice into payload A. If the specified byte slice is not exactly the same size as payload A, then it panics.
func (Message) SetPayloadB ¶
SetPayloadB copies the passed byte slice into payload B. If the specified byte slice is not exactly the same size as payload B, then it panics.
func (Message) SetRawContents ¶
SetRawContents sets the raw contents of the message. This field crosses over the group barrier and the setter of this is responsible for ensuring the underlying payloads are within the group. This will panic if the payload is greater than the maximum size. This overwrites any storage already in the message. If the passed contents is larger than the maximum contents size this will panic.