Documentation ¶
Overview ¶
Package protocol provides address, group, and message structures that the Signal protocol uses for sending encrypted messages.
Index ¶
- Constants
- type CiphertextMessage
- type PreKeySignalMessage
- func NewPreKeySignalMessage(version int, registrationID uint32, preKeyID *optional.Uint32, ...) (*PreKeySignalMessage, error)
- func NewPreKeySignalMessageFromBytes(serialized []byte, serializer PreKeySignalMessageSerializer, ...) (*PreKeySignalMessage, error)
- func NewPreKeySignalMessageFromStruct(structure *PreKeySignalMessageStructure, ...) (*PreKeySignalMessage, error)
- func (p *PreKeySignalMessage) BaseKey() ecc.ECPublicKeyable
- func (p *PreKeySignalMessage) IdentityKey() *identity.Key
- func (p *PreKeySignalMessage) MessageVersion() int
- func (p *PreKeySignalMessage) PreKeyID() *optional.Uint32
- func (p *PreKeySignalMessage) RegistrationID() uint32
- func (p *PreKeySignalMessage) Serialize() []byte
- func (p *PreKeySignalMessage) SignedPreKeyID() uint32
- func (p *PreKeySignalMessage) Type() uint32
- func (p *PreKeySignalMessage) WhisperMessage() *SignalMessage
- type PreKeySignalMessageSerializer
- type PreKeySignalMessageStructure
- type SenderKeyDistributionMessage
- func NewSenderKeyDistributionMessage(id uint32, iteration uint32, chainKey []byte, signatureKey ecc.ECPublicKeyable, ...) *SenderKeyDistributionMessage
- func NewSenderKeyDistributionMessageFromBytes(serialized []byte, serializer SenderKeyDistributionMessageSerializer) (*SenderKeyDistributionMessage, error)
- func NewSenderKeyDistributionMessageFromStruct(structure *SenderKeyDistributionMessageStructure, ...) (*SenderKeyDistributionMessage, error)
- func (p *SenderKeyDistributionMessage) ChainKey() []byte
- func (p *SenderKeyDistributionMessage) ID() uint32
- func (p *SenderKeyDistributionMessage) Iteration() uint32
- func (p *SenderKeyDistributionMessage) Serialize() []byte
- func (p *SenderKeyDistributionMessage) SignatureKey() ecc.ECPublicKeyable
- func (p *SenderKeyDistributionMessage) Type() uint32
- type SenderKeyDistributionMessageSerializer
- type SenderKeyDistributionMessageStructure
- type SenderKeyMessage
- func NewSenderKeyMessage(keyID uint32, iteration uint32, ciphertext []byte, ...) *SenderKeyMessage
- func NewSenderKeyMessageFromBytes(serialized []byte, serializer SenderKeyMessageSerializer) (*SenderKeyMessage, error)
- func NewSenderKeyMessageFromStruct(structure *SenderKeyMessageStructure, serializer SenderKeyMessageSerializer) (*SenderKeyMessage, error)
- func (p *SenderKeyMessage) Ciphertext() []byte
- func (p *SenderKeyMessage) Iteration() uint32
- func (p *SenderKeyMessage) KeyID() uint32
- func (p *SenderKeyMessage) Serialize() []byte
- func (p *SenderKeyMessage) Signature() [64]byte
- func (p *SenderKeyMessage) SignedSerialize() []byte
- func (p *SenderKeyMessage) Type() uint32
- func (p *SenderKeyMessage) Version() uint32
- type SenderKeyMessageSerializer
- type SenderKeyMessageStructure
- type SenderKeyName
- type SignalAddress
- type SignalMessage
- func NewSignalMessage(messageVersion int, counter, previousCounter uint32, macKey []byte, ...) (*SignalMessage, error)
- func NewSignalMessageFromBytes(serialized []byte, serializer SignalMessageSerializer) (*SignalMessage, error)
- func NewSignalMessageFromStruct(structure *SignalMessageStructure, serializer SignalMessageSerializer) (*SignalMessage, error)
- func (s *SignalMessage) Body() []byte
- func (s *SignalMessage) Counter() uint32
- func (s *SignalMessage) MessageVersion() int
- func (s *SignalMessage) SenderRatchetKey() ecc.ECPublicKeyable
- func (s *SignalMessage) Serialize() []byte
- func (s *SignalMessage) Structure() *SignalMessageStructure
- func (s *SignalMessage) Type() uint32
- func (s *SignalMessage) VerifyMac(messageVersion int, senderIdentityKey, receiverIdentityKey *identity.Key, ...) error
- type SignalMessageSerializer
- type SignalMessageStructure
Constants ¶
const ADDRESS_SEPARATOR = "~"
const CurrentVersion = 3
const PREKEY_TYPE = 3
const SENDERKEY_DISTRIBUTION_TYPE = 5
const SENDERKEY_TYPE = 4
const UnsupportedVersion = 1
const WHISPER_TYPE = 2
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CiphertextMessage ¶
type PreKeySignalMessage ¶
type PreKeySignalMessage struct {
// contains filtered or unexported fields
}
PreKeySignalMessage is an encrypted Signal message that is designed to be used when building a session with someone for the first time.
func NewPreKeySignalMessage ¶
func NewPreKeySignalMessage(version int, registrationID uint32, preKeyID *optional.Uint32, signedPreKeyID uint32, baseKey ecc.ECPublicKeyable, identityKey *identity.Key, message *SignalMessage, serializer PreKeySignalMessageSerializer, msgSerializer SignalMessageSerializer) (*PreKeySignalMessage, error)
NewPreKeySignalMessage will return a new PreKeySignalMessage object.
func NewPreKeySignalMessageFromBytes ¶
func NewPreKeySignalMessageFromBytes(serialized []byte, serializer PreKeySignalMessageSerializer, msgSerializer SignalMessageSerializer) (*PreKeySignalMessage, error)
NewPreKeySignalMessageFromBytes will return a Signal Ciphertext message from the given bytes using the given serializer.
func NewPreKeySignalMessageFromStruct ¶
func NewPreKeySignalMessageFromStruct(structure *PreKeySignalMessageStructure, serializer PreKeySignalMessageSerializer, msgSerializer SignalMessageSerializer) (*PreKeySignalMessage, error)
NewPreKeySignalMessageFromStruct will return a new PreKeySignalMessage from the given PreKeySignalMessageStructure.
func (*PreKeySignalMessage) BaseKey ¶
func (p *PreKeySignalMessage) BaseKey() ecc.ECPublicKeyable
func (*PreKeySignalMessage) IdentityKey ¶
func (p *PreKeySignalMessage) IdentityKey() *identity.Key
func (*PreKeySignalMessage) MessageVersion ¶
func (p *PreKeySignalMessage) MessageVersion() int
func (*PreKeySignalMessage) PreKeyID ¶
func (p *PreKeySignalMessage) PreKeyID() *optional.Uint32
func (*PreKeySignalMessage) RegistrationID ¶
func (p *PreKeySignalMessage) RegistrationID() uint32
func (*PreKeySignalMessage) Serialize ¶
func (p *PreKeySignalMessage) Serialize() []byte
func (*PreKeySignalMessage) SignedPreKeyID ¶
func (p *PreKeySignalMessage) SignedPreKeyID() uint32
func (*PreKeySignalMessage) Type ¶
func (p *PreKeySignalMessage) Type() uint32
func (*PreKeySignalMessage) WhisperMessage ¶
func (p *PreKeySignalMessage) WhisperMessage() *SignalMessage
type PreKeySignalMessageSerializer ¶
type PreKeySignalMessageSerializer interface { Serialize(signalMessage *PreKeySignalMessageStructure) []byte Deserialize(serialized []byte) (*PreKeySignalMessageStructure, error) }
PreKeySignalMessageSerializer is an interface for serializing and deserializing PreKeySignalMessages into bytes. An implementation of this interface should be used to encode/decode the object into JSON, Protobuffers, etc.
type PreKeySignalMessageStructure ¶
type PreKeySignalMessageStructure struct { RegistrationID uint32 PreKeyID *optional.Uint32 SignedPreKeyID uint32 BaseKey []byte IdentityKey []byte Message []byte Version int }
PreKeySignalMessageStructure is a serializable structure for PreKeySignalMessages.
type SenderKeyDistributionMessage ¶
type SenderKeyDistributionMessage struct {
// contains filtered or unexported fields
}
SenderKeyDistributionMessage is a structure for senderkey distribution messages.
func NewSenderKeyDistributionMessage ¶
func NewSenderKeyDistributionMessage(id uint32, iteration uint32, chainKey []byte, signatureKey ecc.ECPublicKeyable, serializer SenderKeyDistributionMessageSerializer) *SenderKeyDistributionMessage
NewSenderKeyDistributionMessage returns a Signal Ciphertext message.
func NewSenderKeyDistributionMessageFromBytes ¶
func NewSenderKeyDistributionMessageFromBytes(serialized []byte, serializer SenderKeyDistributionMessageSerializer) (*SenderKeyDistributionMessage, error)
NewSenderKeyDistributionMessageFromBytes will return a Signal Ciphertext message from the given bytes using the given serializer.
func NewSenderKeyDistributionMessageFromStruct ¶
func NewSenderKeyDistributionMessageFromStruct(structure *SenderKeyDistributionMessageStructure, serializer SenderKeyDistributionMessageSerializer) (*SenderKeyDistributionMessage, error)
NewSenderKeyDistributionMessageFromStruct returns a Signal Ciphertext message from the given serializable structure.
func (*SenderKeyDistributionMessage) ChainKey ¶
func (p *SenderKeyDistributionMessage) ChainKey() []byte
ChainKey will return the message's chain key in bytes.
func (*SenderKeyDistributionMessage) ID ¶
func (p *SenderKeyDistributionMessage) ID() uint32
ID will return the message's id.
func (*SenderKeyDistributionMessage) Iteration ¶
func (p *SenderKeyDistributionMessage) Iteration() uint32
Iteration will return the message's iteration.
func (*SenderKeyDistributionMessage) Serialize ¶
func (p *SenderKeyDistributionMessage) Serialize() []byte
Serialize will use the given serializer and return the message as bytes.
func (*SenderKeyDistributionMessage) SignatureKey ¶
func (p *SenderKeyDistributionMessage) SignatureKey() ecc.ECPublicKeyable
SignatureKey will return the message's signature public key
func (*SenderKeyDistributionMessage) Type ¶
func (p *SenderKeyDistributionMessage) Type() uint32
Type will return the message's type.
type SenderKeyDistributionMessageSerializer ¶
type SenderKeyDistributionMessageSerializer interface { Serialize(signalMessage *SenderKeyDistributionMessageStructure) []byte Deserialize(serialized []byte) (*SenderKeyDistributionMessageStructure, error) }
SenderKeyDistributionMessageSerializer is an interface for serializing and deserializing SenderKeyDistributionMessages into bytes. An implementation of this interface should be used to encode/decode the object into JSON, Protobuffers, etc.
type SenderKeyDistributionMessageStructure ¶
type SenderKeyDistributionMessageStructure struct { ID uint32 Iteration uint32 ChainKey []byte SigningKey []byte Version uint32 }
SenderKeyDistributionMessageStructure is a serializeable structure for senderkey distribution messages.
type SenderKeyMessage ¶
type SenderKeyMessage struct {
// contains filtered or unexported fields
}
SenderKeyMessage is a structure for messages using senderkey groups.
func NewSenderKeyMessage ¶
func NewSenderKeyMessage(keyID uint32, iteration uint32, ciphertext []byte, signatureKey ecc.ECPrivateKeyable, serializer SenderKeyMessageSerializer) *SenderKeyMessage
NewSenderKeyMessage returns a SenderKeyMessage.
func NewSenderKeyMessageFromBytes ¶
func NewSenderKeyMessageFromBytes(serialized []byte, serializer SenderKeyMessageSerializer) (*SenderKeyMessage, error)
NewSenderKeyMessageFromBytes will return a Signal Ciphertext message from the given bytes using the given serializer.
func NewSenderKeyMessageFromStruct ¶
func NewSenderKeyMessageFromStruct(structure *SenderKeyMessageStructure, serializer SenderKeyMessageSerializer) (*SenderKeyMessage, error)
NewSenderKeyMessageFromStruct returns a Signal Ciphertext message from the given serializable structure.
func (*SenderKeyMessage) Ciphertext ¶
func (p *SenderKeyMessage) Ciphertext() []byte
Ciphertext returns the SenderKeyMessage encrypted ciphertext.
func (*SenderKeyMessage) Iteration ¶
func (p *SenderKeyMessage) Iteration() uint32
Iteration returns the SenderKeyMessage iteration.
func (*SenderKeyMessage) KeyID ¶
func (p *SenderKeyMessage) KeyID() uint32
KeyID returns the SenderKeyMessage key ID.
func (*SenderKeyMessage) Serialize ¶
func (p *SenderKeyMessage) Serialize() []byte
Serialize will use the given serializer to return the message as bytes excluding the signature. This should be used for signing and verifying message signatures.
func (*SenderKeyMessage) Signature ¶
func (p *SenderKeyMessage) Signature() [64]byte
Signature returns the SenderKeyMessage signature
func (*SenderKeyMessage) SignedSerialize ¶
func (p *SenderKeyMessage) SignedSerialize() []byte
SignedSerialize will use the given serializer to return the message as bytes with the message signature included. This should be used when sending the message over the network.
func (*SenderKeyMessage) Type ¶
func (p *SenderKeyMessage) Type() uint32
Type returns the sender key type.
func (*SenderKeyMessage) Version ¶
func (p *SenderKeyMessage) Version() uint32
Version returns the Signal message version of the message.
type SenderKeyMessageSerializer ¶
type SenderKeyMessageSerializer interface { Serialize(signalMessage *SenderKeyMessageStructure) []byte Deserialize(serialized []byte) (*SenderKeyMessageStructure, error) }
SenderKeyMessageSerializer is an interface for serializing and deserializing SenderKeyMessages into bytes. An implementation of this interface should be used to encode/decode the object into JSON, Protobuffers, etc.
type SenderKeyMessageStructure ¶
type SenderKeyMessageStructure struct { ID uint32 Iteration uint32 CipherText []byte Version uint32 Signature []byte }
SenderKeyMessageStructure is a serializeable structure for SenderKey messages.
type SenderKeyName ¶
type SenderKeyName struct {
// contains filtered or unexported fields
}
SenderKeyName is a structure for a group session address.
func NewSenderKeyName ¶
func NewSenderKeyName(groupID string, sender *SignalAddress) *SenderKeyName
NewSenderKeyName returns a new SenderKeyName object.
func (*SenderKeyName) GroupID ¶
func (n *SenderKeyName) GroupID() string
GroupID returns the sender key group id
func (*SenderKeyName) Sender ¶
func (n *SenderKeyName) Sender() *SignalAddress
Sender returns the Signal address of sending user in the group.
type SignalAddress ¶
type SignalAddress struct {
// contains filtered or unexported fields
}
SignalAddress is a combination of a name and a device ID.
func NewSignalAddress ¶
func NewSignalAddress(name string, deviceID uint32) *SignalAddress
NewSignalAddress returns a new signal address.
func (*SignalAddress) DeviceID ¶
func (s *SignalAddress) DeviceID() uint32
DeviceID returns the signal address's device ID.
func (*SignalAddress) Name ¶
func (s *SignalAddress) Name() string
Name returns the signal address's name.
func (*SignalAddress) String ¶
func (s *SignalAddress) String() string
String returns a string of both the address name and device id.
type SignalMessage ¶
type SignalMessage struct {
// contains filtered or unexported fields
}
SignalMessage is a cipher message that contains a message encrypted with the Signal protocol.
func NewSignalMessage ¶
func NewSignalMessage(messageVersion int, counter, previousCounter uint32, macKey []byte, senderRatchetKey ecc.ECPublicKeyable, ciphertext []byte, senderIdentityKey, receiverIdentityKey *identity.Key, serializer SignalMessageSerializer) (*SignalMessage, error)
NewSignalMessage returns a Signal Ciphertext message.
func NewSignalMessageFromBytes ¶
func NewSignalMessageFromBytes(serialized []byte, serializer SignalMessageSerializer) (*SignalMessage, error)
NewSignalMessageFromBytes will return a Signal Ciphertext message from the given bytes using the given serializer.
func NewSignalMessageFromStruct ¶
func NewSignalMessageFromStruct(structure *SignalMessageStructure, serializer SignalMessageSerializer) (*SignalMessage, error)
NewSignalMessageFromStruct returns a Signal Ciphertext message from the given serializable structure.
func (*SignalMessage) Body ¶
func (s *SignalMessage) Body() []byte
Body will return the SignalMessage's ciphertext in bytes.
func (*SignalMessage) Counter ¶
func (s *SignalMessage) Counter() uint32
Counter will return the SignalMessage counter.
func (*SignalMessage) MessageVersion ¶
func (s *SignalMessage) MessageVersion() int
MessageVersion returns the message version this SignalMessage supports.
func (*SignalMessage) SenderRatchetKey ¶
func (s *SignalMessage) SenderRatchetKey() ecc.ECPublicKeyable
SenderRatchetKey returns the SignalMessage's sender ratchet key. This key is used for ratcheting the chain forward to negotiate a new shared secret that cannot be derived from previous chains.
func (*SignalMessage) Serialize ¶
func (s *SignalMessage) Serialize() []byte
Serialize will return the Signal Message as bytes.
func (*SignalMessage) Structure ¶
func (s *SignalMessage) Structure() *SignalMessageStructure
Structure will return a serializeable structure of the Signal Message.
func (*SignalMessage) Type ¶
func (s *SignalMessage) Type() uint32
Type will return the type of Signal Message this is.
func (*SignalMessage) VerifyMac ¶
func (s *SignalMessage) VerifyMac(messageVersion int, senderIdentityKey, receiverIdentityKey *identity.Key, macKey []byte) error
VerifyMac will return an error if the message's message authentication code is invalid. This should be used on SignalMessages that have been constructed from a sent message.
type SignalMessageSerializer ¶
type SignalMessageSerializer interface { Serialize(signalMessage *SignalMessageStructure) []byte Deserialize(serialized []byte) (*SignalMessageStructure, error) }
SignalMessageSerializer is an interface for serializing and deserializing SignalMessages into bytes. An implementation of this interface should be used to encode/decode the object into JSON, Protobuffers, etc.