libsignalgo

package
v0.5.1-mod-1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

README

libsignalgo

Go bindings for libsignal.

Installation

  1. Install Rust. You may also need to install libclang-dev and cbindgen manually.
  2. Clone libsignal somewhere.
  3. Run ./update-ffi.sh <path to libsignal> (this builds the library, regenerates the header, and copies them both here)
  4. Copy libsignal_ffi.a to /usr/lib/.
    • Alternatively, set LIBRARY_PATH to the directory containing libsignal_ffi.a. Something like this: LIBRARY_PATH="$LIBRARY_PATH:./pkg/libsignalgo" ./build.sh
  5. Use like a normal Go library.

Precompiled

You can find precompiled libsignal_ffi.a's on mau.dev/tulir/gomuks-build-docker. Direct links:

Documentation

Index

Constants

View Source
const Version = "v0.41.0"

Variables

This section is empty.

Functions

func BorrowedMutableBuffer

func BorrowedMutableBuffer(length int) C.SignalBorrowedMutableBuffer

func BytesToBuffer

func BytesToBuffer(data []byte) C.SignalBorrowedBuffer

func CopyBufferToBytes

func CopyBufferToBytes(buffer *C.uchar, length C.size_t) (b []byte)

func CopyCStringToString

func CopyCStringToString(cString *C.char) (s string)

func CopySignalOwnedBufferToBytes

func CopySignalOwnedBufferToBytes(buffer C.SignalOwnedBuffer) (b []byte)

func Decrypt

func Decrypt(ctx context.Context, message *Message, fromAddress *Address, sessionStore SessionStore, identityStore IdentityKeyStore) ([]byte, error)

func DecryptPreKey

func DecryptPreKey(ctx context.Context, preKeyMessage *PreKeyMessage, fromAddress *Address, sessionStore SessionStore, identityStore IdentityKeyStore, preKeyStore PreKeyStore, signedPreKeyStore SignedPreKeyStore, kyberPreKeyStore KyberPreKeyStore) ([]byte, error)

func EmptyBorrowedBuffer

func EmptyBorrowedBuffer() C.SignalBorrowedBuffer

func GroupDecrypt

func GroupDecrypt(ctx context.Context, ctext []byte, sender *Address, store SenderKeyStore) ([]byte, error)

func HKDFDerive

func HKDFDerive(outputLength int, inputKeyMaterial, salt, info []byte) ([]byte, error)

func InitLogger

func InitLogger(level LogLevel, logger Logger)

func ProcessPreKeyBundle

func ProcessPreKeyBundle(ctx context.Context, bundle *PreKeyBundle, forAddress *Address, sessionStore SessionStore, identityStore IdentityKeyStore) error

func ProcessSenderKeyDistributionMessage

func ProcessSenderKeyDistributionMessage(ctx context.Context, message *SenderKeyDistributionMessage, fromSender *Address, store SenderKeyStore) error

func SealedSenderEncrypt

func SealedSenderEncrypt(ctx context.Context, usmc *UnidentifiedSenderMessageContent, forRecipient *Address, identityStore IdentityKeyStore) ([]byte, error)

func SealedSenderEncryptPlaintext

func SealedSenderEncryptPlaintext(ctx context.Context, message []byte, forAddress *Address, fromSenderCert *SenderCertificate, sessionStore SessionStore, identityStore IdentityKeyStore) ([]byte, error)

func SealedSenderMultiRecipientEncrypt

func SealedSenderMultiRecipientEncrypt(messageContent *UnidentifiedSenderMessageContent, forRecipients []*Address, identityStore IdentityKeyStore, sessionStore SessionStore, ctx *CallbackContext) ([]byte, error)

func ServerPublicParamsVerifySignature

func ServerPublicParamsVerifySignature(
	serverPublicParams ServerPublicParams,
	messageBytes []byte,
	NotarySignature NotarySignature,
) error

func SignalPNIServiceIDFromUUID

func SignalPNIServiceIDFromUUID(uuid uuid.UUID) (cPNIType, error)

func SignalServiceIDFromUUID

func SignalServiceIDFromUUID(uuid uuid.UUID) (cPNIType, error)

func SignalServiceIDToUUID

func SignalServiceIDToUUID(serviceId *C.SignalServiceIdFixedWidthBinaryBytes) (uuid.UUID, error)

Types

type AES256_GCM_SIV

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

func NewAES256_GCM_SIV

func NewAES256_GCM_SIV(key []byte) (*AES256_GCM_SIV, error)

func (*AES256_GCM_SIV) Decrypt

func (aes *AES256_GCM_SIV) Decrypt(ciphertext, nonce, associatedData []byte) ([]byte, error)

func (*AES256_GCM_SIV) Destroy

func (aes *AES256_GCM_SIV) Destroy() error

func (*AES256_GCM_SIV) Encrypt

func (aes *AES256_GCM_SIV) Encrypt(plaintext, nonce, associatedData []byte) ([]byte, error)

type AccessKey

type AccessKey [C.SignalACCESS_KEY_LEN]byte

func (*AccessKey) String

func (ak *AccessKey) String() string

type Address

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

func NewPhoneAddress deprecated

func NewPhoneAddress(phone string, deviceID uint) (*Address, error)

Deprecated: phone addresses are not used anymore

func NewUUIDAddress

func NewUUIDAddress(u uuid.UUID, deviceID uint) (*Address, error)

func NewUUIDAddressFromString

func NewUUIDAddressFromString(uuidStr string, deviceID uint) (*Address, error)

func (*Address) CancelFinalizer

func (pa *Address) CancelFinalizer()

func (*Address) Clone

func (pa *Address) Clone() (*Address, error)

func (*Address) Destroy

func (pa *Address) Destroy() error

func (*Address) DeviceID

func (pa *Address) DeviceID() (uint, error)

func (*Address) Name

func (pa *Address) Name() (string, error)

func (*Address) NameUUID

func (pa *Address) NameUUID() (uuid.UUID, error)

type AuthCredentialPresentation

type AuthCredentialPresentation []byte

func CreateAuthCredentialWithPniPresentation

func CreateAuthCredentialWithPniPresentation(
	serverPublicParams ServerPublicParams,
	randomness Randomness,
	groupSecretParams GroupSecretParams,
	authCredWithPni AuthCredentialWithPni,
) (*AuthCredentialPresentation, error)

type AuthCredentialWithPni

type AuthCredentialWithPni [C.SignalAUTH_CREDENTIAL_WITH_PNI_LEN]byte

type AuthCredential [C.SignalAUTH_CREDENTIAL_LEN]byte type AuthCredentialResponse [C.SignalAUTH_CREDENTIAL_RESPONSE_LEN]byte

func ReceiveAuthCredentialWithPni

func ReceiveAuthCredentialWithPni(
	serverPublicParams ServerPublicParams,
	aci uuid.UUID,
	pni uuid.UUID,
	redemptionTime uint64,
	authCredResponse AuthCredentialWithPniResponse,
) (*AuthCredentialWithPni, error)

func (*AuthCredentialWithPni) Slice

func (ac *AuthCredentialWithPni) Slice() []byte

type AuthCredentialWithPniResponse

type AuthCredentialWithPniResponse [C.SignalAUTH_CREDENTIAL_WITH_PNI_RESPONSE_LEN]byte

func NewAuthCredentialWithPniResponse

func NewAuthCredentialWithPniResponse(b []byte) (*AuthCredentialWithPniResponse, error)

type CallbackContext

type CallbackContext struct {
	Error  error
	Ctx    context.Context
	Unrefs []unsafe.Pointer
}

func NewCallbackContext

func NewCallbackContext(ctx context.Context) *CallbackContext

func (*CallbackContext) Unref

func (ctx *CallbackContext) Unref()

type CiphertextMessage

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

func Encrypt

func Encrypt(ctx context.Context, plaintext []byte, forAddress *Address, sessionStore SessionStore, identityKeyStore IdentityKeyStore) (*CiphertextMessage, error)

func GroupEncrypt

func GroupEncrypt(ctx context.Context, ptext []byte, sender *Address, distributionID uuid.UUID, store SenderKeyStore) (*CiphertextMessage, error)

func NewCiphertextMessage

func NewCiphertextMessage(plaintext *PlaintextContent) (*CiphertextMessage, error)

func (*CiphertextMessage) CancelFinalizer

func (c *CiphertextMessage) CancelFinalizer()

func (*CiphertextMessage) Destroy

func (c *CiphertextMessage) Destroy() error

func (*CiphertextMessage) MessageType

func (c *CiphertextMessage) MessageType() (CiphertextMessageType, error)

func (*CiphertextMessage) Serialize

func (c *CiphertextMessage) Serialize() ([]byte, error)

type CiphertextMessageType

type CiphertextMessageType uint8
const (
	CiphertextMessageTypeWhisper   CiphertextMessageType = 2
	CiphertextMessageTypePreKey    CiphertextMessageType = 3
	CiphertextMessageTypeSenderKey CiphertextMessageType = 7
	CiphertextMessageTypePlaintext CiphertextMessageType = 8
)

type DecryptionErrorMessage

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

func DecryptionErrorMessageForOriginalMessage

func DecryptionErrorMessageForOriginalMessage(originalBytes []byte, originalType uint8, originalTs uint64, originalSenderDeviceID uint) (*DecryptionErrorMessage, error)

func DecryptionErrorMessageFromSerializedContent

func DecryptionErrorMessageFromSerializedContent(serialized []byte) (*DecryptionErrorMessage, error)

func DeserializeDecryptionErrorMessage

func DeserializeDecryptionErrorMessage(messageBytes []byte) (*DecryptionErrorMessage, error)

func (*DecryptionErrorMessage) CancelFinalizer

func (dem *DecryptionErrorMessage) CancelFinalizer()

func (*DecryptionErrorMessage) Clone

func (*DecryptionErrorMessage) Destroy

func (dem *DecryptionErrorMessage) Destroy() error

func (*DecryptionErrorMessage) GetDeviceID

func (dem *DecryptionErrorMessage) GetDeviceID() (uint32, error)

func (*DecryptionErrorMessage) GetRatchetKey

func (dem *DecryptionErrorMessage) GetRatchetKey() (*PublicKey, error)

func (*DecryptionErrorMessage) GetTimestamp

func (dem *DecryptionErrorMessage) GetTimestamp() (time.Time, error)

func (*DecryptionErrorMessage) Serialize

func (dem *DecryptionErrorMessage) Serialize() ([]byte, error)

type DeviceTransferKey

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

func GenerateDeviceTransferKey

func GenerateDeviceTransferKey() (*DeviceTransferKey, error)

func (*DeviceTransferKey) GenerateCertificate

func (dtk *DeviceTransferKey) GenerateCertificate(name string, days int) ([]byte, error)

func (*DeviceTransferKey) PrivateKeyMaterial

func (dtk *DeviceTransferKey) PrivateKeyMaterial() []byte

type ErrorCode

type ErrorCode int
const (
	ErrorCodeUnknownError               ErrorCode = 1
	ErrorCodeInvalidState               ErrorCode = 2
	ErrorCodeInternalError              ErrorCode = 3
	ErrorCodeNullParameter              ErrorCode = 4
	ErrorCodeInvalidArgument            ErrorCode = 5
	ErrorCodeInvalidType                ErrorCode = 6
	ErrorCodeInvalidUtf8String          ErrorCode = 7
	ErrorCodeProtobufError              ErrorCode = 10
	ErrorCodeLegacyCiphertextVersion    ErrorCode = 21
	ErrorCodeUnknownCiphertextVersion   ErrorCode = 22
	ErrorCodeUnrecognizedMessageVersion ErrorCode = 23
	ErrorCodeInvalidMessage             ErrorCode = 30
	ErrorCodeSealedSenderSelfSend       ErrorCode = 31
	ErrorCodeInvalidKey                 ErrorCode = 40
	ErrorCodeInvalidSignature           ErrorCode = 41
	ErrorCodeInvalidAttestationData     ErrorCode = 42
	ErrorCodeFingerprintVersionMismatch ErrorCode = 51
	ErrorCodeFingerprintParsingError    ErrorCode = 52
	ErrorCodeUntrustedIdentity          ErrorCode = 60
	ErrorCodeInvalidKeyIdentifier       ErrorCode = 70
	ErrorCodeSessionNotFound            ErrorCode = 80
	ErrorCodeInvalidRegistrationId      ErrorCode = 81
	ErrorCodeInvalidSession             ErrorCode = 82
	ErrorCodeInvalidSenderKeySession    ErrorCode = 83
	ErrorCodeDuplicatedMessage          ErrorCode = 90
	ErrorCodeCallbackError              ErrorCode = 100
	ErrorCodeVerificationFailure        ErrorCode = 110
)

type Fingerprint

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

func NewFingerprint

func NewFingerprint(iterations, version FingerprintVersion, localIdentifier []byte, localKey *PublicKey, remoteIdentifier []byte, remoteKey *PublicKey) (*Fingerprint, error)

func (*Fingerprint) Clone

func (f *Fingerprint) Clone() (*Fingerprint, error)

func (*Fingerprint) Compare

func (f *Fingerprint) Compare(fingerprint1, fingerprint2 []byte) (bool, error)

func (*Fingerprint) Destroy

func (f *Fingerprint) Destroy() error

func (*Fingerprint) DisplayString

func (f *Fingerprint) DisplayString() (string, error)

func (*Fingerprint) ScannableEncoding

func (f *Fingerprint) ScannableEncoding() ([]byte, error)

type FingerprintVersion

type FingerprintVersion uint32
const (
	FingerprintVersionV1 FingerprintVersion = 1
	FingerprintVersionV2 FingerprintVersion = 2
)

type GroupIdentifier

type GroupIdentifier [C.SignalGROUP_IDENTIFIER_LEN]byte

func GetGroupIdentifier

func GetGroupIdentifier(groupPublicParams GroupPublicParams) (*GroupIdentifier, error)

type GroupMasterKey

type GroupMasterKey [C.SignalGROUP_MASTER_KEY_LEN]byte

type GroupSecretParams

type GroupSecretParams [C.SignalGROUP_SECRET_PARAMS_LEN]byte

func DeriveGroupSecretParamsFromMasterKey

func DeriveGroupSecretParamsFromMasterKey(groupMasterKey GroupMasterKey) (GroupSecretParams, error)

func GenerateGroupSecretParams

func GenerateGroupSecretParams() (GroupSecretParams, error)

func GenerateGroupSecretParamsWithRandomness

func GenerateGroupSecretParamsWithRandomness(randomness Randomness) (GroupSecretParams, error)

func (*GroupSecretParams) DecryptBlobWithPadding

func (gsp *GroupSecretParams) DecryptBlobWithPadding(blob []byte) ([]byte, error)

func (*GroupSecretParams) DecryptProfileKey

func (gsp *GroupSecretParams) DecryptProfileKey(ciphertextProfileKey ProfileKeyCiphertext, u uuid.UUID) (*ProfileKey, error)

func (*GroupSecretParams) DecryptUUID

func (gsp *GroupSecretParams) DecryptUUID(ciphertextUUID UUIDCiphertext) (uuid.UUID, error)

func (*GroupSecretParams) GetPublicParams

func (gsp *GroupSecretParams) GetPublicParams() (*GroupPublicParams, error)

type HSMEnclaveClient

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

func NewHSMEnclaveClient

func NewHSMEnclaveClient(trustedPublicKey, trustedCodeHashes []byte) (*HSMEnclaveClient, error)

func (*HSMEnclaveClient) CompleteHandshake

func (hsm *HSMEnclaveClient) CompleteHandshake(handshakeReceived []byte) error

func (*HSMEnclaveClient) Destroy

func (hsm *HSMEnclaveClient) Destroy() error

func (*HSMEnclaveClient) EstablishedReceive

func (hsm *HSMEnclaveClient) EstablishedReceive(ciphertext []byte) ([]byte, error)

func (*HSMEnclaveClient) EstablishedSend

func (hsm *HSMEnclaveClient) EstablishedSend(plaintext []byte) ([]byte, error)

func (*HSMEnclaveClient) InitialRequest

func (hsm *HSMEnclaveClient) InitialRequest() ([]byte, error)

type IdentityKey

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

func DeserializeIdentityKey

func DeserializeIdentityKey(bytes []byte) (*IdentityKey, error)

func NewIdentityKeyFromBytes

func NewIdentityKeyFromBytes(bytes []byte) (*IdentityKey, error)

func NewIdentityKeyFromPublicKey

func NewIdentityKeyFromPublicKey(publicKey *PublicKey) (*IdentityKey, error)

func (*IdentityKey) Equal

func (i *IdentityKey) Equal(other *IdentityKey) (bool, error)

func (*IdentityKey) Serialize

func (i *IdentityKey) Serialize() ([]byte, error)

func (*IdentityKey) VerifyAlternateIdentity

func (i *IdentityKey) VerifyAlternateIdentity(other *IdentityKey, signature []byte) (bool, error)

type IdentityKeyPair

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

func DeserializeIdentityKeyPair

func DeserializeIdentityKeyPair(bytes []byte) (*IdentityKeyPair, error)

func GenerateIdentityKeyPair

func GenerateIdentityKeyPair() (*IdentityKeyPair, error)

func NewIdentityKeyPair

func NewIdentityKeyPair(publicKey *PublicKey, privateKey *PrivateKey) (*IdentityKeyPair, error)

func (*IdentityKeyPair) GetIdentityKey

func (i *IdentityKeyPair) GetIdentityKey() *IdentityKey

func (*IdentityKeyPair) GetPrivateKey

func (i *IdentityKeyPair) GetPrivateKey() *PrivateKey

func (*IdentityKeyPair) GetPublicKey

func (i *IdentityKeyPair) GetPublicKey() *PublicKey

func (*IdentityKeyPair) Serialize

func (i *IdentityKeyPair) Serialize() ([]byte, error)

func (*IdentityKeyPair) SignAlternateIdentity

func (i *IdentityKeyPair) SignAlternateIdentity(other *IdentityKey) ([]byte, error)

type IdentityKeyStore

type IdentityKeyStore interface {
	GetIdentityKeyPair(ctx context.Context) (*IdentityKeyPair, error)
	GetLocalRegistrationID(ctx context.Context) (uint32, error)
	SaveIdentityKey(ctx context.Context, address *Address, identityKey *IdentityKey) (bool, error)
	GetIdentityKey(ctx context.Context, address *Address) (*IdentityKey, error)
	IsTrustedIdentity(ctx context.Context, address *Address, identityKey *IdentityKey, direction SignalDirection) (bool, error)
}

type KyberKeyPair

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

func KyberKeyPairGenerate

func KyberKeyPairGenerate() (*KyberKeyPair, error)

func (*KyberKeyPair) CancelFinalizer

func (kp *KyberKeyPair) CancelFinalizer()

func (*KyberKeyPair) Destroy

func (kp *KyberKeyPair) Destroy() error

func (*KyberKeyPair) GetPublicKey

func (kp *KyberKeyPair) GetPublicKey() (*KyberPublicKey, error)

type KyberPreKeyRecord

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

func DeserializeKyberPreKeyRecord

func DeserializeKyberPreKeyRecord(serialized []byte) (*KyberPreKeyRecord, error)

func NewKyberPreKeyRecord

func NewKyberPreKeyRecord(id uint32, timestamp time.Time, keyPair *KyberKeyPair, signature []byte) (*KyberPreKeyRecord, error)

func (*KyberPreKeyRecord) CancelFinalizer

func (kpkr *KyberPreKeyRecord) CancelFinalizer()

func (*KyberPreKeyRecord) Clone

func (kpkr *KyberPreKeyRecord) Clone() (*KyberPreKeyRecord, error)

func (*KyberPreKeyRecord) Destroy

func (kpkr *KyberPreKeyRecord) Destroy() error

func (*KyberPreKeyRecord) GetID

func (kpkr *KyberPreKeyRecord) GetID() (uint, error)

func (*KyberPreKeyRecord) GetPublicKey

func (kpkr *KyberPreKeyRecord) GetPublicKey() (*KyberPublicKey, error)

func (*KyberPreKeyRecord) GetSecretKey

func (kpkr *KyberPreKeyRecord) GetSecretKey() (*KyberSecretKey, error)

func (*KyberPreKeyRecord) GetSignature

func (kpkr *KyberPreKeyRecord) GetSignature() ([]byte, error)

func (*KyberPreKeyRecord) GetTimestamp

func (kpkr *KyberPreKeyRecord) GetTimestamp() (time.Time, error)

func (*KyberPreKeyRecord) Serialize

func (kpkr *KyberPreKeyRecord) Serialize() ([]byte, error)

type KyberPreKeyStore

type KyberPreKeyStore interface {
	LoadKyberPreKey(ctx context.Context, id uint32) (*KyberPreKeyRecord, error)
	StoreKyberPreKey(ctx context.Context, id uint32, kyberPreKeyRecord *KyberPreKeyRecord) error
	MarkKyberPreKeyUsed(ctx context.Context, id uint32) error
}

type KyberPublicKey

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

func DeserializeKyberPublicKey

func DeserializeKyberPublicKey(serialized []byte) (*KyberPublicKey, error)

func (*KyberPublicKey) CancelFinalizer

func (k *KyberPublicKey) CancelFinalizer()

func (*KyberPublicKey) Destroy

func (k *KyberPublicKey) Destroy() error

func (*KyberPublicKey) Serialize

func (kp *KyberPublicKey) Serialize() ([]byte, error)

type KyberSecretKey

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

func (*KyberSecretKey) CancelFinalizer

func (k *KyberSecretKey) CancelFinalizer()

func (*KyberSecretKey) Destroy

func (k *KyberSecretKey) Destroy() error

type LogLevel

type LogLevel int
const (
	LogLevelError LogLevel = iota + 1
	LogLevelWarn
	LogLevelInfo
	LogLevelDebug
	LogLevelTrace
)

type Logger

type Logger interface {
	Enabled(target string, level LogLevel) bool
	Log(target string, level LogLevel, file string, line uint, message string)
	Flush()
}

type Message

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

func DeserializeMessage

func DeserializeMessage(serialized []byte) (*Message, error)

func (*Message) CancelFinalizer

func (m *Message) CancelFinalizer()

func (*Message) Clone

func (m *Message) Clone() (*Message, error)

func (*Message) Destroy

func (m *Message) Destroy() error

func (*Message) GetBody

func (m *Message) GetBody() ([]byte, error)

func (*Message) GetCounter

func (m *Message) GetCounter() (uint32, error)

func (*Message) GetMessageVersion

func (m *Message) GetMessageVersion() (uint32, error)

func (*Message) Serialize

func (m *Message) Serialize() ([]byte, error)

func (*Message) VerifyMAC

func (m *Message) VerifyMAC(sender, receiver *PublicKey, macKey []byte) (bool, error)

type NotarySignature

type NotarySignature [C.SignalSIGNATURE_LEN]byte

type PlaintextContent

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

func DeserializePlaintextContent

func DeserializePlaintextContent(plaintextContentBytes []byte) (*PlaintextContent, error)

func PlaintextContentFromDecryptionErrorMessage

func PlaintextContentFromDecryptionErrorMessage(message *DecryptionErrorMessage) (*PlaintextContent, error)

func (*PlaintextContent) CancelFinalizer

func (pc *PlaintextContent) CancelFinalizer()

func (*PlaintextContent) Clone

func (pc *PlaintextContent) Clone() (*PlaintextContent, error)

func (*PlaintextContent) Destroy

func (pc *PlaintextContent) Destroy() error

func (*PlaintextContent) GetBody

func (pc *PlaintextContent) GetBody() ([]byte, error)

func (*PlaintextContent) Serialize

func (pc *PlaintextContent) Serialize() ([]byte, error)

type PreKeyBundle

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

func NewPreKeyBundle

func NewPreKeyBundle(
	registrationID uint32,
	deviceID uint32,
	preKeyID uint32,
	preKey *PublicKey,
	signedPreKeyID uint32,
	signedPreKey *PublicKey,
	signedPreKeySignature []byte,
	kyberPreKeyID uint32,
	kyberPreKey *KyberPublicKey,
	kyberPreKeySignature []byte,
	identityKey *IdentityKey,
) (*PreKeyBundle, error)

func (*PreKeyBundle) CancelFinalizer

func (pkb *PreKeyBundle) CancelFinalizer()

func (*PreKeyBundle) Clone

func (pkb *PreKeyBundle) Clone() (*PreKeyBundle, error)

func (*PreKeyBundle) Destroy

func (pkb *PreKeyBundle) Destroy() error

func (*PreKeyBundle) GetIdentityKey

func (pkb *PreKeyBundle) GetIdentityKey() (*IdentityKey, error)

type PreKeyMessage

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

func DeserializePreKeyMessage

func DeserializePreKeyMessage(serialized []byte) (*PreKeyMessage, error)

func (*PreKeyMessage) CancelFinalizer

func (m *PreKeyMessage) CancelFinalizer()

func (*PreKeyMessage) Clone

func (m *PreKeyMessage) Clone() (*PreKeyMessage, error)

func (*PreKeyMessage) Destroy

func (m *PreKeyMessage) Destroy() error

func (*PreKeyMessage) GetBaseKey

func (m *PreKeyMessage) GetBaseKey() (*PublicKey, error)

func (*PreKeyMessage) GetIdentityKey

func (m *PreKeyMessage) GetIdentityKey() (*IdentityKey, error)

func (*PreKeyMessage) GetPreKeyID

func (m *PreKeyMessage) GetPreKeyID() (*uint32, error)

func (*PreKeyMessage) GetRegistrationID

func (m *PreKeyMessage) GetRegistrationID() (uint32, error)

func (*PreKeyMessage) GetSignalMessage

func (m *PreKeyMessage) GetSignalMessage() (*Message, error)

func (*PreKeyMessage) GetSignedPreKeyID

func (m *PreKeyMessage) GetSignedPreKeyID() (uint32, error)

func (*PreKeyMessage) GetVersion

func (m *PreKeyMessage) GetVersion() (uint32, error)

func (*PreKeyMessage) Serialize

func (m *PreKeyMessage) Serialize() ([]byte, error)

type PreKeyRecord

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

func DeserializePreKeyRecord

func DeserializePreKeyRecord(serialized []byte) (*PreKeyRecord, error)

func NewPreKeyRecord

func NewPreKeyRecord(id uint32, publicKey *PublicKey, privateKey *PrivateKey) (*PreKeyRecord, error)

func NewPreKeyRecordFromPrivateKey

func NewPreKeyRecordFromPrivateKey(id uint32, privateKey *PrivateKey) (*PreKeyRecord, error)

func (*PreKeyRecord) CancelFinalizer

func (pkr *PreKeyRecord) CancelFinalizer()

func (*PreKeyRecord) Clone

func (pkr *PreKeyRecord) Clone() (*PreKeyRecord, error)

func (*PreKeyRecord) Destroy

func (pkr *PreKeyRecord) Destroy() error

func (*PreKeyRecord) GetID

func (pkr *PreKeyRecord) GetID() (uint, error)

func (*PreKeyRecord) GetPrivateKey

func (pkr *PreKeyRecord) GetPrivateKey() (*PrivateKey, error)

func (*PreKeyRecord) GetPublicKey

func (pkr *PreKeyRecord) GetPublicKey() (*PublicKey, error)

func (*PreKeyRecord) Serialize

func (pkr *PreKeyRecord) Serialize() ([]byte, error)

type PreKeyStore

type PreKeyStore interface {
	LoadPreKey(ctx context.Context, id uint32) (*PreKeyRecord, error)
	StorePreKey(ctx context.Context, id uint32, preKeyRecord *PreKeyRecord) error
	RemovePreKey(ctx context.Context, id uint32) error
}

type PrivateKey

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

func DeserializePrivateKey

func DeserializePrivateKey(keyData []byte) (*PrivateKey, error)

func GeneratePrivateKey

func GeneratePrivateKey() (*PrivateKey, error)

func (*PrivateKey) Agree

func (pk *PrivateKey) Agree(publicKey *PublicKey) ([]byte, error)

func (*PrivateKey) CancelFinalizer

func (pk *PrivateKey) CancelFinalizer()

func (*PrivateKey) Clone

func (pk *PrivateKey) Clone() (*PrivateKey, error)

func (*PrivateKey) Destroy

func (pk *PrivateKey) Destroy() error

func (*PrivateKey) GetPublicKey

func (pk *PrivateKey) GetPublicKey() (*PublicKey, error)

func (*PrivateKey) Serialize

func (pk *PrivateKey) Serialize() ([]byte, error)

func (*PrivateKey) Sign

func (pk *PrivateKey) Sign(message []byte) ([]byte, error)

type ProfileKey

type ProfileKey [C.SignalPROFILE_KEY_LEN]byte

func (*ProfileKey) DeriveAccessKey

func (pk *ProfileKey) DeriveAccessKey() (*AccessKey, error)

func (*ProfileKey) GetCommitment

func (pk *ProfileKey) GetCommitment(u uuid.UUID) (*ProfileKeyCommitment, error)

func (*ProfileKey) GetProfileKeyVersion

func (pk *ProfileKey) GetProfileKeyVersion(u uuid.UUID) (*ProfileKeyVersion, error)

func (*ProfileKey) IsEmpty

func (pk *ProfileKey) IsEmpty() bool

func (*ProfileKey) Slice

func (pk *ProfileKey) Slice() []byte

type ProfileKeyCredentialPresentation

type ProfileKeyCredentialPresentation []byte

type ProfileKeyCredentialRequestContext

type ProfileKeyCredentialRequestContext [C.SignalPROFILE_KEY_CREDENTIAL_REQUEST_CONTEXT_LEN]byte

func CreateProfileKeyCredentialRequestContext

func CreateProfileKeyCredentialRequestContext(serverPublicParams ServerPublicParams, u uuid.UUID, profileKey ProfileKey) (*ProfileKeyCredentialRequestContext, error)

func (*ProfileKeyCredentialRequestContext) ProfileKeyCredentialRequestContextGetRequest

func (p *ProfileKeyCredentialRequestContext) ProfileKeyCredentialRequestContextGetRequest() (*ProfileKeyCredentialRequest, error)

type ProfileKeyCredentialResponse

type ProfileKeyCredentialResponse []byte

func NewProfileKeyCredentialResponse

func NewProfileKeyCredentialResponse(b []byte) (ProfileKeyCredentialResponse, error)

type ProfileKeyVersion

type ProfileKeyVersion [C.SignalPROFILE_KEY_VERSION_ENCODED_LEN]byte

func (*ProfileKeyVersion) String

func (pv *ProfileKeyVersion) String() string

type PublicKey

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

func DeserializePublicKey

func DeserializePublicKey(keyData []byte) (*PublicKey, error)

func (*PublicKey) Bytes

func (k *PublicKey) Bytes() ([]byte, error)

func (*PublicKey) CancelFinalizer

func (k *PublicKey) CancelFinalizer()

func (*PublicKey) Clone

func (pk *PublicKey) Clone() (*PublicKey, error)

func (*PublicKey) Compare

func (k *PublicKey) Compare(other *PublicKey) (int, error)

func (*PublicKey) Destroy

func (k *PublicKey) Destroy() error

func (*PublicKey) Serialize

func (pk *PublicKey) Serialize() ([]byte, error)

func (*PublicKey) Verify

func (k *PublicKey) Verify(message, signature []byte) (bool, error)

type Randomness

type Randomness [C.SignalRANDOMNESS_LEN]byte

func GenerateRandomness

func GenerateRandomness() Randomness

type SGXClientState

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

func NewCDS2ClientState

func NewCDS2ClientState(mrenclave, attestationMessage []byte, currentTime time.Time) (*SGXClientState, error)

func (*SGXClientState) CompleteHandshake

func (cds *SGXClientState) CompleteHandshake(handshakeReceived []byte) error

func (*SGXClientState) Destroy

func (cds *SGXClientState) Destroy() error

func (*SGXClientState) EstablishedReceive

func (cds *SGXClientState) EstablishedReceive(ciphertext []byte) ([]byte, error)

func (*SGXClientState) EstablishedSend

func (cds *SGXClientState) EstablishedSend(plaintext []byte) ([]byte, error)

func (*SGXClientState) InitialRequest

func (cds *SGXClientState) InitialRequest() ([]byte, error)

type SealedSenderAddress

type SealedSenderAddress struct {
	E164     string
	UUID     uuid.UUID
	DeviceID uint32
}

func NewSealedSenderAddress

func NewSealedSenderAddress(e164 string, uuid uuid.UUID, deviceID uint32) *SealedSenderAddress

type SealedSenderResult

type SealedSenderResult struct {
	Message []byte
	Sender  SealedSenderAddress
}

func SealedSenderDecrypt

func SealedSenderDecrypt(
	ctx context.Context,
	ciphertext []byte,
	localAddress *SealedSenderAddress,
	trustRoot *PublicKey,
	timestamp time.Time,
	sessionStore SessionStore,
	identityStore IdentityKeyStore,
	preKeyStore PreKeyStore,
	signedPreKeyStore SignedPreKeyStore,
) (result SealedSenderResult, err error)

type SenderCertificate

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

func DeserializeSenderCertificate

func DeserializeSenderCertificate(serialized []byte) (*SenderCertificate, error)

func NewSenderCertificate

func NewSenderCertificate(sender *SealedSenderAddress, publicKey *PublicKey, expiration time.Time, signerCertificate *ServerCertificate, signerKey *PrivateKey) (*SenderCertificate, error)

NewSenderCertificate should only be used for testing (at least according to the Swift bindings).

func (*SenderCertificate) CancelFinalizer

func (sc *SenderCertificate) CancelFinalizer()

func (*SenderCertificate) Clone

func (sc *SenderCertificate) Clone() (*SenderCertificate, error)

func (*SenderCertificate) Destroy

func (sc *SenderCertificate) Destroy() error

func (*SenderCertificate) GetCertificate

func (sc *SenderCertificate) GetCertificate() ([]byte, error)

func (*SenderCertificate) GetDeviceID

func (sc *SenderCertificate) GetDeviceID() (uint32, error)

func (*SenderCertificate) GetExpiration

func (sc *SenderCertificate) GetExpiration() (time.Time, error)

func (*SenderCertificate) GetKey

func (sc *SenderCertificate) GetKey() (*PublicKey, error)

func (*SenderCertificate) GetSenderE164

func (sc *SenderCertificate) GetSenderE164() (string, error)

func (*SenderCertificate) GetSenderUUID

func (sc *SenderCertificate) GetSenderUUID() (uuid.UUID, error)

func (*SenderCertificate) GetServerCertificate

func (sc *SenderCertificate) GetServerCertificate() (*ServerCertificate, error)

func (*SenderCertificate) GetSignature

func (sc *SenderCertificate) GetSignature() ([]byte, error)

func (*SenderCertificate) Serialize

func (sc *SenderCertificate) Serialize() ([]byte, error)

func (*SenderCertificate) Validate

func (sc *SenderCertificate) Validate(trustRoot *PublicKey, ts time.Time) (bool, error)

type SenderKeyDistributionMessage

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

func DeserializeSenderKeyDistributionMessage

func DeserializeSenderKeyDistributionMessage(serialized []byte) (*SenderKeyDistributionMessage, error)

func NewSenderKeyDistributionMessage

func NewSenderKeyDistributionMessage(ctx context.Context, sender *Address, distributionID uuid.UUID, store SenderKeyStore) (*SenderKeyDistributionMessage, error)

func (*SenderKeyDistributionMessage) CancelFinalizer

func (sc *SenderKeyDistributionMessage) CancelFinalizer()

func (*SenderKeyDistributionMessage) Destroy

func (sc *SenderKeyDistributionMessage) Destroy() error

func (*SenderKeyDistributionMessage) Process

func (sc *SenderKeyDistributionMessage) Process(ctx context.Context, sender *Address, store SenderKeyStore) error

func (*SenderKeyDistributionMessage) Serialize

func (sc *SenderKeyDistributionMessage) Serialize() ([]byte, error)

type SenderKeyRecord

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

func DeserializeSenderKeyRecord

func DeserializeSenderKeyRecord(serialized []byte) (*SenderKeyRecord, error)

func (*SenderKeyRecord) CancelFinalizer

func (skr *SenderKeyRecord) CancelFinalizer()

func (*SenderKeyRecord) Clone

func (skr *SenderKeyRecord) Clone() (*SenderKeyRecord, error)

func (*SenderKeyRecord) Destroy

func (skr *SenderKeyRecord) Destroy() error

func (*SenderKeyRecord) Serialize

func (skr *SenderKeyRecord) Serialize() ([]byte, error)

type SenderKeyStore

type SenderKeyStore interface {
	LoadSenderKey(ctx context.Context, sender *Address, distributionID uuid.UUID) (*SenderKeyRecord, error)
	StoreSenderKey(ctx context.Context, sender *Address, distributionID uuid.UUID, record *SenderKeyRecord) error
}

type ServerCertificate

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

func DeserializeServerCertificate

func DeserializeServerCertificate(serialized []byte) (*ServerCertificate, error)

func NewServerCertificate

func NewServerCertificate(keyID uint32, publicKey *PublicKey, trustRoot *PrivateKey) (*ServerCertificate, error)

NewServerCertificate should only be used for testing (at least according to the Swift bindings).

func (*ServerCertificate) CancelFinalizer

func (sc *ServerCertificate) CancelFinalizer()

func (*ServerCertificate) Clone

func (sc *ServerCertificate) Clone() (*ServerCertificate, error)

func (*ServerCertificate) Destroy

func (sc *ServerCertificate) Destroy() error

func (*ServerCertificate) GetCertificate

func (sc *ServerCertificate) GetCertificate() ([]byte, error)

func (*ServerCertificate) GetKey

func (sc *ServerCertificate) GetKey() (*PublicKey, error)

func (*ServerCertificate) GetKeyID

func (sc *ServerCertificate) GetKeyID() (uint32, error)

func (*ServerCertificate) GetSignature

func (sc *ServerCertificate) GetSignature() ([]byte, error)

func (*ServerCertificate) Serialize

func (sc *ServerCertificate) Serialize() ([]byte, error)

type SessionRecord

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

func DeserializeSessionRecord

func DeserializeSessionRecord(serialized []byte) (*SessionRecord, error)

func (*SessionRecord) ArchiveCurrentState

func (sr *SessionRecord) ArchiveCurrentState() error

func (*SessionRecord) CancelFinalizer

func (sr *SessionRecord) CancelFinalizer()

func (*SessionRecord) Clone

func (sr *SessionRecord) Clone() (*SessionRecord, error)

func (*SessionRecord) CurrentRatchetKeyMatches

func (sr *SessionRecord) CurrentRatchetKeyMatches(key *PublicKey) (bool, error)

func (*SessionRecord) Destroy

func (sr *SessionRecord) Destroy() error

func (*SessionRecord) GetLocalRegistrationID

func (sr *SessionRecord) GetLocalRegistrationID() (uint32, error)

func (*SessionRecord) GetRemoteRegistrationID

func (sr *SessionRecord) GetRemoteRegistrationID() (uint32, error)

func (*SessionRecord) HasCurrentState

func (sr *SessionRecord) HasCurrentState() (bool, error)

func (*SessionRecord) Serialize

func (sr *SessionRecord) Serialize() ([]byte, error)

type SessionStore

type SessionStore interface {
	LoadSession(ctx context.Context, address *Address) (*SessionRecord, error)
	StoreSession(ctx context.Context, address *Address, record *SessionRecord) error
}

type SignalDirection

type SignalDirection uint
const (
	SignalDirectionSending   SignalDirection = 0
	SignalDirectionReceiving SignalDirection = 1
)

type SignalError

type SignalError struct {
	Code    ErrorCode
	Message string
}

func (*SignalError) Error

func (e *SignalError) Error() string

type SignedPreKeyRecord

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

func DeserializeSignedPreKeyRecord

func DeserializeSignedPreKeyRecord(serialized []byte) (*SignedPreKeyRecord, error)

func NewSignedPreKeyRecord

func NewSignedPreKeyRecord(id uint32, timestamp time.Time, publicKey *PublicKey, privateKey *PrivateKey, signature []byte) (*SignedPreKeyRecord, error)

func NewSignedPreKeyRecordFromPrivateKey

func NewSignedPreKeyRecordFromPrivateKey(id uint32, timestamp time.Time, privateKey *PrivateKey, signature []byte) (*SignedPreKeyRecord, error)

func (*SignedPreKeyRecord) CancelFinalizer

func (spkr *SignedPreKeyRecord) CancelFinalizer()

func (*SignedPreKeyRecord) Clone

func (spkr *SignedPreKeyRecord) Clone() (*SignedPreKeyRecord, error)

func (*SignedPreKeyRecord) Destroy

func (spkr *SignedPreKeyRecord) Destroy() error

func (*SignedPreKeyRecord) GetID

func (spkr *SignedPreKeyRecord) GetID() (uint, error)

func (*SignedPreKeyRecord) GetPrivateKey

func (spkr *SignedPreKeyRecord) GetPrivateKey() (*PrivateKey, error)

func (*SignedPreKeyRecord) GetPublicKey

func (spkr *SignedPreKeyRecord) GetPublicKey() (*PublicKey, error)

func (*SignedPreKeyRecord) GetSignature

func (spkr *SignedPreKeyRecord) GetSignature() ([]byte, error)

func (*SignedPreKeyRecord) GetTimestamp

func (spkr *SignedPreKeyRecord) GetTimestamp() (time.Time, error)

func (*SignedPreKeyRecord) Serialize

func (spkr *SignedPreKeyRecord) Serialize() ([]byte, error)

type SignedPreKeyStore

type SignedPreKeyStore interface {
	LoadSignedPreKey(ctx context.Context, id uint32) (*SignedPreKeyRecord, error)
	StoreSignedPreKey(ctx context.Context, id uint32, signedPreKeyRecord *SignedPreKeyRecord) error
}

type UUIDCiphertext

type UUIDCiphertext [C.SignalUUID_CIPHERTEXT_LEN]byte

type UnidentifiedSenderMessageContent

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

func DeserializeUnidentifiedSenderMessageContent

func DeserializeUnidentifiedSenderMessageContent(serialized []byte) (*UnidentifiedSenderMessageContent, error)

func NewUnidentifiedSenderMessageContent

func NewUnidentifiedSenderMessageContent(message *CiphertextMessage, senderCertificate *SenderCertificate, contentHint UnidentifiedSenderMessageContentHint, groupID []byte) (*UnidentifiedSenderMessageContent, error)

func SealedSenderDecryptToUSMC

func SealedSenderDecryptToUSMC(
	ctx context.Context,
	ciphertext []byte,
	identityStore IdentityKeyStore,
) (*UnidentifiedSenderMessageContent, error)

func (*UnidentifiedSenderMessageContent) CancelFinalizer

func (usmc *UnidentifiedSenderMessageContent) CancelFinalizer()

func (*UnidentifiedSenderMessageContent) Destroy

func (usmc *UnidentifiedSenderMessageContent) Destroy() error

func (*UnidentifiedSenderMessageContent) GetContentHint

func (*UnidentifiedSenderMessageContent) GetContents

func (usmc *UnidentifiedSenderMessageContent) GetContents() ([]byte, error)

func (*UnidentifiedSenderMessageContent) GetMessageType

func (*UnidentifiedSenderMessageContent) GetSenderCertificate

func (usmc *UnidentifiedSenderMessageContent) GetSenderCertificate() (*SenderCertificate, error)

func (*UnidentifiedSenderMessageContent) Serialize

func (usmc *UnidentifiedSenderMessageContent) Serialize() ([]byte, error)

type UnidentifiedSenderMessageContentHint

type UnidentifiedSenderMessageContentHint uint32
const (
	UnidentifiedSenderMessageContentHintDefault    UnidentifiedSenderMessageContentHint = 0
	UnidentifiedSenderMessageContentHintResendable UnidentifiedSenderMessageContentHint = 1
	UnidentifiedSenderMessageContentHintImplicit   UnidentifiedSenderMessageContentHint = 2
)

type WrappedStore

type WrappedStore[T any] struct {
	Store T
	Ctx   *CallbackContext
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL