Documentation ¶
Index ¶
- Constants
- func CheckKeyFingerprint(fingerprint format.Fingerprint, groupKey Key, salt [SaltLen]byte, ...) bool
- func CheckMAC(mac []byte, key CryptKey, encryptedInternalMsg []byte, ...) bool
- func ComputeEpoch(t time.Time) uint32
- func Decrypt(key CryptKey, keyFingerprint format.Fingerprint, encryptedInternalMsg []byte) []byte
- func Encrypt(key CryptKey, keyFingerprint format.Fingerprint, internalMsg []byte) []byte
- func NewID(preimage IdPreimage, membership Membership) *id.ID
- func NewKeyFingerprint(groupKey Key, salt [32]byte, recipientID *id.ID) format.Fingerprint
- func NewMAC(key CryptKey, encryptedInternalMsg []byte, recipientDhKey *cyclic.Int) []byte
- type CryptKey
- type IdPreimage
- type Key
- type KeyPreimage
- type Member
- type Membership
- type MessageID
Constants ¶
const ( KeyLen = 32 // Group key KeyPreimageLen = 32 // Key preimage )
Length of data, in bytes.
const ( // MinMembers is the minimum number of members allowed in a Membership list. MinMembers = 2 // MaxMembers is the minimum number of members allowed in a Membership list. MaxMembers = 11 // MinParticipants is the minimum number of participants allowed when // creating a new Membership list. MinParticipants = MinMembers - 1 // MaxParticipants is the maximum number of participants allowed when // creating a new Membership list. MaxParticipants = MaxMembers - 1 )
const CryptKeyLen = 32
CryptKeyLen is the length, in bytes, of the KDF key.
const IdPreimageLen = 32
IdPreimageLen is the length, in bytes, of the ID preimage.
const MessageIdLen = 32
MessageIdLen is the length, in bytes, of the message ID.
const SaltLen = 32
SaltLen is the length, in bytes, of the salt used to generate the key fingerprint.
Variables ¶
This section is empty.
Functions ¶
func CheckKeyFingerprint ¶
func CheckKeyFingerprint(fingerprint format.Fingerprint, groupKey Key, salt [SaltLen]byte, recipientID *id.ID) bool
CheckKeyFingerprint verifies that the given fingerprint matches the provided group data.
func CheckMAC ¶
func CheckMAC(mac []byte, key CryptKey, encryptedInternalMsg []byte, recipientDhKey *cyclic.Int) bool
CheckMAC verifies that the given MAC matches the provided data.
func ComputeEpoch ¶
ComputeEpoch generates an epoch for the given time.
func Decrypt ¶
func Decrypt(key CryptKey, keyFingerprint format.Fingerprint, encryptedInternalMsg []byte) []byte
Decrypt decrypts the encrypted internal message with XChaCha20.
func Encrypt ¶
func Encrypt(key CryptKey, keyFingerprint format.Fingerprint, internalMsg []byte) []byte
Encrypt encrypts the internal message with XChaCha20.
func NewID ¶
func NewID(preimage IdPreimage, membership Membership) *id.ID
NewID generates a new id.ID of type id.Group. The ID is a hash of the group Membership digest, a 256-bit preimage, and a constant.
func NewKeyFingerprint ¶
NewKeyFingerprint generates a key fingerprint for the member of a group from the group key, 256-bit salt, and the member's recipient ID.
Types ¶
type CryptKey ¶
type CryptKey [CryptKeyLen]byte
CryptKey is the 256-bit key used for encryption/decryption.
type IdPreimage ¶
type IdPreimage [IdPreimageLen]byte
IdPreimage is the 256-bit group ID preimage generated from a CRNG.
func NewIdPreimage ¶
func NewIdPreimage(rng io.Reader) (IdPreimage, error)
NewIdPreimage generates a 256-bit preimage from a CRNG that is used for group ID generation. An error is returned if the RNG does not return the correct number of bytes.
func (IdPreimage) Bytes ¶
func (idp IdPreimage) Bytes() []byte
Bytes returns the IdPreimage as a byte slice.
func (IdPreimage) String ¶
func (idp IdPreimage) String() string
String returns the IdPreimage as a base 64 encoded string. This functions satisfies the fmt.Stringer interface.
type Key ¶
Key is the 256-bit group key.
func NewKey ¶
func NewKey(preimage KeyPreimage, membership Membership) Key
NewKey generates a new key for a group. The key is a hash of the group Membership digest, a 256-bit preimage, and a constant. An error is returned if the preimage is not of the correct size.
type KeyPreimage ¶
type KeyPreimage [KeyPreimageLen]byte
KeyPreimage is the 256-bit group key preimage generated from a CRNG.
func NewKeyPreimage ¶
func NewKeyPreimage(rng io.Reader) (KeyPreimage, error)
NewKeyPreimage generates a 256-bit preimage from a CRNG that is used for group key generation. An error is returned if the RNG does not return the correct number of bytes.
func (KeyPreimage) Bytes ¶
func (kp KeyPreimage) Bytes() []byte
Bytes returns the KeyPreimage as a byte slice.
func (KeyPreimage) String ¶
func (kp KeyPreimage) String() string
String returns the KeyPreimage as a base 64 encoded string. This functions satisfies the fmt.Stringer interface.
type Member ¶
type Member struct { ID *id.ID // Group member's user ID DhKey *cyclic.Int // Group member's public Diffie–Hellman key }
Member describes each user in a group membership list.
func DeserializeMember ¶
DeserializeMember deserializes the bytes into a Member.
func (Member) Equal ¶
Equal returns true if the two Members have the same ID and Diffie–Hellman key.
func (Member) GoString ¶
GoString returns the member's ID and full Diffie–Hellman key as text. This functions satisfies the fmt.GoStringer interface.
type Membership ¶
type Membership []Member
Membership is a list of members in a group. The group leader is always the first in the list followed by all group members sorted by their ID smallest to largest.
func DeserializeMembership ¶
func DeserializeMembership(b []byte) (Membership, error)
DeserializeMembership deserializes the bytes into a Membership.
func NewMembership ¶
NewMembership returns a new Membership list with the provided leader and participants.
func (Membership) DeepCopy ¶
func (gm Membership) DeepCopy() Membership
DeepCopy returns a deep copy of the Membership.
func (Membership) Digest ¶
func (gm Membership) Digest() []byte
Digest generates a hash of all the reception IDs and Diffie–Hellman keys of each member in the order presented in the Membership list.
func (Membership) Serialize ¶
func (gm Membership) Serialize() []byte
Serialize generates a byte representation of the Membership for sending over the wire.
func (Membership) String ¶
func (gm Membership) String() string
String returns a list of members as text. This functions satisfies the fmt.Stringer interface.
type MessageID ¶
type MessageID [MessageIdLen]byte
MessageID is the 256-bit unique ID that identifies a message.
func NewMessageID ¶
NewMessageID generates an ID for a group message by hashing the group ID and the internal message format.