libsignalgo.mau.fi/libsignal/keys/message Index | Files

package message

import "go.mau.fi/libsignal/keys/message"

Package message provides a structure for message keys, which are symmetric keys used for the encryption/decryption of Signal messages.

Index

Constants

const CipherKeyLength = 32

CipherKeyLength is the length of the actual cipher key used for messages.

const DerivedSecretsSize = 80

DerivedSecretsSize is the size of the derived secrets for message keys.

const IVLength = 16

IVLength is the length of the initialization vector in bytes.

const KdfSalt string = "WhisperMessageKeys"

KdfSalt is used as the Salt for message keys to derive secrets using a Key Derivation Function

const MacKeyLength = 32

MacKeyLength is the length of the message authentication code in bytes.

Types

type Keys

type Keys struct {
	// contains filtered or unexported fields
}

Keys is a structure to hold all the keys for a single MessageKey, including the cipherKey, mac, iv, and index of the chain key. MessageKeys are used to encrypt individual messages.

func NewKeys

func NewKeys(cipherKey, macKey, iv []byte, index uint32) *Keys

NewKeys returns a new message keys structure with the given cipherKey, mac, iv, and index.

func NewKeysFromStruct

func NewKeysFromStruct(structure *KeysStructure) *Keys

NewKeysFromStruct will return a new message keys object from the given serializeable structure.

func (*Keys) CipherKey

func (k *Keys) CipherKey() []byte

CipherKey is the key used to produce ciphertext.

func (*Keys) Index

func (k *Keys) Index() uint32

Index returns the number of times the chain key has been put through a key derivation function to generate this message key.

func (*Keys) Iv

func (k *Keys) Iv() []byte

Iv returns the message keys' initialization vector. The IV is a fixed-size input to a cryptographic primitive.

func (*Keys) MacKey

func (k *Keys) MacKey() []byte

MacKey returns the message's message authentication code.

type KeysStructure

type KeysStructure struct {
	CipherKey []byte
	MacKey    []byte
	IV        []byte
	Index     uint32
}

KeysStructure is a serializeable structure of message keys.

func NewStructFromKeys

func NewStructFromKeys(keys *Keys) *KeysStructure

NewStructFromKeys returns a serializeable structure of message keys.

Source Files

MessageKey.go

Version
v0.1.2 (latest)
Published
Feb 12, 2025
Platform
linux/amd64
Last checked
1 week ago

Tools for package owners.