Documentation ¶
Index ¶
- Constants
- func RatchetErrorHandleStatus(status C.vscr_status_t) error
- type GroupMsgType
- type MsgType
- type RatchetCommon
- type RatchetError
- type RatchetGroupMessage
- func (obj *RatchetGroupMessage) Ctx() uintptr
- func (obj *RatchetGroupMessage) Delete()
- func (obj *RatchetGroupMessage) GetCounter() uint32
- func (obj *RatchetGroupMessage) GetEpoch() uint32
- func (obj *RatchetGroupMessage) GetSessionId() []byte
- func (obj *RatchetGroupMessage) GetType() GroupMsgType
- func (obj *RatchetGroupMessage) Serialize() []byte
- func (obj *RatchetGroupMessage) SerializeLen() uint
- type RatchetGroupParticipantsIds
- type RatchetGroupParticipantsInfo
- type RatchetGroupSession
- func (obj *RatchetGroupSession) CreateGroupTicket() (*RatchetGroupTicket, error)
- func (obj *RatchetGroupSession) Ctx() uintptr
- func (obj *RatchetGroupSession) Decrypt(message *RatchetGroupMessage, senderId []byte) ([]byte, error)
- func (obj *RatchetGroupSession) DecryptLen(message *RatchetGroupMessage) uint
- func (obj *RatchetGroupSession) Delete()
- func (obj *RatchetGroupSession) Encrypt(plainText []byte) (*RatchetGroupMessage, error)
- func (obj *RatchetGroupSession) GetCurrentEpoch() uint32
- func (obj *RatchetGroupSession) GetMyId() []byte
- func (obj *RatchetGroupSession) GetParticipantsCount() uint32
- func (obj *RatchetGroupSession) GetSessionId() []byte
- func (obj *RatchetGroupSession) IsInitialized() bool
- func (obj *RatchetGroupSession) IsMyIdSet() bool
- func (obj *RatchetGroupSession) IsPrivateKeySet() bool
- func (obj *RatchetGroupSession) Serialize() []byte
- func (obj *RatchetGroupSession) SetMyId(myId []byte)
- func (obj *RatchetGroupSession) SetPrivateKey(myPrivateKey []byte) error
- func (obj *RatchetGroupSession) SetRng(rng foundation.Random)
- func (obj *RatchetGroupSession) SetupDefaults() error
- func (obj *RatchetGroupSession) SetupSessionState(message *RatchetGroupMessage, participants *RatchetGroupParticipantsInfo) error
- func (obj *RatchetGroupSession) UpdateSessionState(message *RatchetGroupMessage, addParticipants *RatchetGroupParticipantsInfo, ...) error
- type RatchetGroupTicket
- func (obj *RatchetGroupTicket) Ctx() uintptr
- func (obj *RatchetGroupTicket) Delete()
- func (obj *RatchetGroupTicket) GetTicketMessage() *RatchetGroupMessage
- func (obj *RatchetGroupTicket) SetRng(rng foundation.Random)
- func (obj *RatchetGroupTicket) SetupDefaults() error
- func (obj *RatchetGroupTicket) SetupTicketAsNew(sessionId []byte) error
- type RatchetImplementation
- type RatchetKeyId
- type RatchetMessage
- func (obj *RatchetMessage) Ctx() uintptr
- func (obj *RatchetMessage) Delete()
- func (obj *RatchetMessage) GetCounter() uint32
- func (obj *RatchetMessage) GetLongTermPublicKey() []byte
- func (obj *RatchetMessage) GetOneTimePublicKey() []byte
- func (obj *RatchetMessage) GetType() MsgType
- func (obj *RatchetMessage) Serialize() []byte
- func (obj *RatchetMessage) SerializeLen() uint
- type RatchetSession
- func (obj *RatchetSession) Ctx() uintptr
- func (obj *RatchetSession) Decrypt(message *RatchetMessage) ([]byte, error)
- func (obj *RatchetSession) DecryptLen(message *RatchetMessage) uint
- func (obj *RatchetSession) Delete()
- func (obj *RatchetSession) Encrypt(plainText []byte) (*RatchetMessage, error)
- func (obj *RatchetSession) Initiate(senderIdentityPrivateKey []byte, receiverIdentityPublicKey []byte, ...) error
- func (obj *RatchetSession) IsInitiator() bool
- func (obj *RatchetSession) ReceivedFirstResponse() bool
- func (obj *RatchetSession) ReceiverHasOneTimePublicKey() bool
- func (obj *RatchetSession) Respond(senderIdentityPublicKey []byte, receiverIdentityPrivateKey []byte, ...) error
- func (obj *RatchetSession) Serialize() []byte
- func (obj *RatchetSession) SetRng(rng foundation.Random)
- func (obj *RatchetSession) SetupDefaults() error
Constants ¶
const ( /* * Max plain text length allowed to be encrypted */ RatchetCommonMaxPlainTextLen uint = 30000 /* * Max message length */ RatchetCommonMaxMessageLen uint = 32975 /* * Key pair id length */ RatchetCommonKeyIdLen uint = 8 /* * Participant id length */ RatchetCommonParticipantIdLen uint = 32 /* * Session id length */ RatchetCommonSessionIdLen uint = 32 /* * Max number of group chat participants */ RatchetCommonMaxParticipantsCount uint = 100 /* * Min number of group chat participants */ RatchetCommonMinParticipantsCount uint = 2 /* * Max group message length */ RatchetCommonMaxGroupMessageLen uint = 32918 )
const ( /* * Error during protobuf deserialization. */ RatchetErrorErrorProtobufDecode int = -1 /* * Bad message type. */ RatchetErrorErrorBadMessageType int = -2 /* * AES error. */ RatchetErrorErrorAes int = -3 /* * RNG failed. */ RatchetErrorErrorRngFailed int = -4 /* * Curve25519 error. */ RatchetErrorErrorCurve25519 int = -5 /* * Curve25519 error. */ RatchetErrorErrorEd25519 int = -6 /* * Key deserialization failed. */ RatchetErrorErrorKeyDeserializationFailed int = -7 /* * Invalid key type. */ RatchetErrorErrorInvalidKeyType int = -8 /* * Identity key doesn't match. */ RatchetErrorErrorIdentityKeyDoesntMatch int = -9 /* * Message already decrypted. */ RatchetErrorErrorMessageAlreadyDecrypted int = -10 /* * Too many lost messages. */ RatchetErrorErrorTooManyLostMessages int = -11 /* * Sender chain missing. */ RatchetErrorErrorSenderChainMissing int = -12 /* * Skipped message missing. */ RatchetErrorErrorSkippedMessageMissing int = -13 /* * Session is not initialized. */ RatchetErrorErrorSessionIsNotInitialized int = -14 /* * Exceeded max plain text len. */ RatchetErrorErrorExceededMaxPlainTextLen int = -15 /* * Too many messages for sender chain. */ RatchetErrorErrorTooManyMessagesForSenderChain int = -16 /* * Too many messages for receiver chain. */ RatchetErrorErrorTooManyMessagesForReceiverChain int = -17 /* * Invalid padding. */ RatchetErrorErrorInvalidPadding int = -18 /* * Too many participants. */ RatchetErrorErrorTooManyParticipants int = -19 /* * Too few participants. */ RatchetErrorErrorTooFewParticipants int = -20 /* * Sender not found. */ RatchetErrorErrorSenderNotFound int = -21 /* * Cannot decrypt own messages. */ RatchetErrorErrorCannotDecryptOwnMessages int = -22 /* * Invalid signature. */ RatchetErrorErrorInvalidSignature int = -23 /* * Cannot remove myself. */ RatchetErrorErrorCannotRemoveMyself int = -24 /* * Epoch mismatch. */ RatchetErrorErrorEpochMismatch int = -25 /* * Epoch not found. */ RatchetErrorErrorEpochNotFound int = -26 /* * Session id mismatch. */ RatchetErrorErrorSessionIdMismatch int = -27 /* * Simultaneous group user operation. */ RatchetErrorErrorSimultaneousGroupUserOperation int = -28 /* * Myself is included in info. */ RatchetErrorErrorMyselfIsIncludedInInfo int = -29 )
Variables ¶
This section is empty.
Functions ¶
func RatchetErrorHandleStatus ¶
func RatchetErrorHandleStatus(status C.vscr_status_t) error
Check given C status, and if it's not "success" then raise correspond error.
Types ¶
type GroupMsgType ¶
type GroupMsgType int
* Represents group message type
const ( /* * Group info used to create group chat, add or remove participants. * Should be distributed only using secure channels. */ GroupMsgTypeGroupInfo GroupMsgType = 1 /* * Regular group ratchet message with cipher text. */ GroupMsgTypeRegular GroupMsgType = 2 )
type RatchetError ¶
* Defines the library status codes.
func (*RatchetError) Error ¶
func (obj *RatchetError) Error() string
type RatchetGroupMessage ¶
type RatchetGroupMessage struct {
// contains filtered or unexported fields
}
* Class represents ratchet group message
func NewRatchetGroupMessage ¶
func NewRatchetGroupMessage() *RatchetGroupMessage
func RatchetGroupMessageDeserialize ¶
func RatchetGroupMessageDeserialize(input []byte) (*RatchetGroupMessage, error)
* Deserializes instance.
func (*RatchetGroupMessage) Ctx ¶
func (obj *RatchetGroupMessage) Ctx() uintptr
Handle underlying C context.
func (*RatchetGroupMessage) Delete ¶
func (obj *RatchetGroupMessage) Delete()
* Release underlying C context.
func (*RatchetGroupMessage) GetCounter ¶
func (obj *RatchetGroupMessage) GetCounter() uint32
* Returns message counter in current epoch.
func (*RatchetGroupMessage) GetEpoch ¶
func (obj *RatchetGroupMessage) GetEpoch() uint32
* Returns message epoch.
func (*RatchetGroupMessage) GetSessionId ¶
func (obj *RatchetGroupMessage) GetSessionId() []byte
* Returns session id. * This method should be called only for group info type.
func (*RatchetGroupMessage) GetType ¶
func (obj *RatchetGroupMessage) GetType() GroupMsgType
* Returns message type.
func (*RatchetGroupMessage) Serialize ¶
func (obj *RatchetGroupMessage) Serialize() []byte
* Serializes instance.
func (*RatchetGroupMessage) SerializeLen ¶
func (obj *RatchetGroupMessage) SerializeLen() uint
* Buffer len to serialize this class.
type RatchetGroupParticipantsIds ¶
type RatchetGroupParticipantsIds struct {
// contains filtered or unexported fields
}
* Container for array of participants ids
func NewRatchetGroupParticipantsIds ¶
func NewRatchetGroupParticipantsIds() *RatchetGroupParticipantsIds
func NewRatchetGroupParticipantsIdsSize ¶
func NewRatchetGroupParticipantsIdsSize(size uint32) *RatchetGroupParticipantsIds
* Creates new array for size elements
func (*RatchetGroupParticipantsIds) AddId ¶
func (obj *RatchetGroupParticipantsIds) AddId(id []byte)
* Add participant id to array
func (*RatchetGroupParticipantsIds) Ctx ¶
func (obj *RatchetGroupParticipantsIds) Ctx() uintptr
Handle underlying C context.
func (*RatchetGroupParticipantsIds) Delete ¶
func (obj *RatchetGroupParticipantsIds) Delete()
* Release underlying C context.
type RatchetGroupParticipantsInfo ¶
type RatchetGroupParticipantsInfo struct {
// contains filtered or unexported fields
}
* Container for array of participants' info
func NewRatchetGroupParticipantsInfo ¶
func NewRatchetGroupParticipantsInfo() *RatchetGroupParticipantsInfo
func NewRatchetGroupParticipantsInfoSize ¶
func NewRatchetGroupParticipantsInfoSize(size uint32) *RatchetGroupParticipantsInfo
* Creates new array for size elements
func (*RatchetGroupParticipantsInfo) AddParticipant ¶
func (obj *RatchetGroupParticipantsInfo) AddParticipant(id []byte, pubKey []byte) error
* Add participant info
func (*RatchetGroupParticipantsInfo) Ctx ¶
func (obj *RatchetGroupParticipantsInfo) Ctx() uintptr
Handle underlying C context.
func (*RatchetGroupParticipantsInfo) Delete ¶
func (obj *RatchetGroupParticipantsInfo) Delete()
* Release underlying C context.
type RatchetGroupSession ¶
type RatchetGroupSession struct {
// contains filtered or unexported fields
}
* Ratchet group session.
func NewRatchetGroupSession ¶
func NewRatchetGroupSession() *RatchetGroupSession
func RatchetGroupSessionDeserialize ¶
func RatchetGroupSessionDeserialize(input []byte) (*RatchetGroupSession, error)
* Deserializes session from buffer. * NOTE: Deserialized session needs dependencies to be set. * You should set separately: * - rng * - my private key
func (*RatchetGroupSession) CreateGroupTicket ¶
func (obj *RatchetGroupSession) CreateGroupTicket() (*RatchetGroupTicket, error)
* Creates ticket with new key for adding or removing participants.
func (*RatchetGroupSession) Ctx ¶
func (obj *RatchetGroupSession) Ctx() uintptr
Handle underlying C context.
func (*RatchetGroupSession) Decrypt ¶
func (obj *RatchetGroupSession) Decrypt(message *RatchetGroupMessage, senderId []byte) ([]byte, error)
* Decrypts message
func (*RatchetGroupSession) DecryptLen ¶
func (obj *RatchetGroupSession) DecryptLen(message *RatchetGroupMessage) uint
* Calculates size of buffer sufficient to store decrypted message
func (*RatchetGroupSession) Delete ¶
func (obj *RatchetGroupSession) Delete()
* Release underlying C context.
func (*RatchetGroupSession) Encrypt ¶
func (obj *RatchetGroupSession) Encrypt(plainText []byte) (*RatchetGroupMessage, error)
* Encrypts data
func (*RatchetGroupSession) GetCurrentEpoch ¶
func (obj *RatchetGroupSession) GetCurrentEpoch() uint32
* Returns current epoch.
func (*RatchetGroupSession) GetMyId ¶
func (obj *RatchetGroupSession) GetMyId() []byte
* Returns my id.
func (*RatchetGroupSession) GetParticipantsCount ¶
func (obj *RatchetGroupSession) GetParticipantsCount() uint32
* Returns number of participants.
func (*RatchetGroupSession) GetSessionId ¶
func (obj *RatchetGroupSession) GetSessionId() []byte
* Returns session id.
func (*RatchetGroupSession) IsInitialized ¶
func (obj *RatchetGroupSession) IsInitialized() bool
* Shows whether session was initialized.
func (*RatchetGroupSession) IsMyIdSet ¶
func (obj *RatchetGroupSession) IsMyIdSet() bool
* Shows whether my id was set.
func (*RatchetGroupSession) IsPrivateKeySet ¶
func (obj *RatchetGroupSession) IsPrivateKeySet() bool
* Shows whether identity private key was set.
func (*RatchetGroupSession) Serialize ¶
func (obj *RatchetGroupSession) Serialize() []byte
* Serializes session to buffer * NOTE: Session changes its state every encrypt/decrypt operations. Be sure to save it.
func (*RatchetGroupSession) SetMyId ¶
func (obj *RatchetGroupSession) SetMyId(myId []byte)
* Sets my id. Should be 32 byte
func (*RatchetGroupSession) SetPrivateKey ¶
func (obj *RatchetGroupSession) SetPrivateKey(myPrivateKey []byte) error
* Sets identity private key.
func (*RatchetGroupSession) SetRng ¶
func (obj *RatchetGroupSession) SetRng(rng foundation.Random)
* Random
func (*RatchetGroupSession) SetupDefaults ¶
func (obj *RatchetGroupSession) SetupDefaults() error
* Setups default dependencies: * - RNG: CTR DRBG
func (*RatchetGroupSession) SetupSessionState ¶
func (obj *RatchetGroupSession) SetupSessionState(message *RatchetGroupMessage, participants *RatchetGroupParticipantsInfo) error
* Sets up session. * Use this method when you have newer epoch message and know all participants info. * NOTE: Identity private key and my id should be set separately.
func (*RatchetGroupSession) UpdateSessionState ¶
func (obj *RatchetGroupSession) UpdateSessionState(message *RatchetGroupMessage, addParticipants *RatchetGroupParticipantsInfo, removeParticipants *RatchetGroupParticipantsIds) error
* Sets up session. * Use this method when you have message with next epoch, and you know how participants set was changed. * NOTE: Identity private key and my id should be set separately.
type RatchetGroupTicket ¶
type RatchetGroupTicket struct {
// contains filtered or unexported fields
}
* Group ticket used to start group session or change participants.
func NewRatchetGroupTicket ¶
func NewRatchetGroupTicket() *RatchetGroupTicket
func (*RatchetGroupTicket) Ctx ¶
func (obj *RatchetGroupTicket) Ctx() uintptr
Handle underlying C context.
func (*RatchetGroupTicket) Delete ¶
func (obj *RatchetGroupTicket) Delete()
* Release underlying C context.
func (*RatchetGroupTicket) GetTicketMessage ¶
func (obj *RatchetGroupTicket) GetTicketMessage() *RatchetGroupMessage
* Returns message that should be sent to all participants using secure channel.
func (*RatchetGroupTicket) SetRng ¶
func (obj *RatchetGroupTicket) SetRng(rng foundation.Random)
* Random used to generate keys
func (*RatchetGroupTicket) SetupDefaults ¶
func (obj *RatchetGroupTicket) SetupDefaults() error
* Setups default dependencies: * - RNG: CTR DRBG
func (*RatchetGroupTicket) SetupTicketAsNew ¶
func (obj *RatchetGroupTicket) SetupTicketAsNew(sessionId []byte) error
* Set this ticket to start new group session.
type RatchetImplementation ¶
type RatchetImplementation struct { }
type RatchetKeyId ¶
type RatchetKeyId struct {
// contains filtered or unexported fields
}
* Utils class for working with keys formats.
func NewRatchetKeyId ¶
func NewRatchetKeyId() *RatchetKeyId
func (*RatchetKeyId) ComputePublicKeyId ¶
func (obj *RatchetKeyId) ComputePublicKeyId(publicKey []byte) ([]byte, error)
* Computes 8 bytes key pair id from Curve25519 (in PKCS8 or raw format) public key
type RatchetMessage ¶
type RatchetMessage struct {
// contains filtered or unexported fields
}
* Class represents ratchet message
func NewRatchetMessage ¶
func NewRatchetMessage() *RatchetMessage
func RatchetMessageDeserialize ¶
func RatchetMessageDeserialize(input []byte) (*RatchetMessage, error)
* Deserializes instance.
func (*RatchetMessage) GetCounter ¶
func (obj *RatchetMessage) GetCounter() uint32
* Returns message counter in current asymmetric ratchet round.
func (*RatchetMessage) GetLongTermPublicKey ¶
func (obj *RatchetMessage) GetLongTermPublicKey() []byte
* Returns long-term public key, if message is prekey message.
func (*RatchetMessage) GetOneTimePublicKey ¶
func (obj *RatchetMessage) GetOneTimePublicKey() []byte
* Returns one-time public key, if message is prekey message and if one-time key is present, empty result otherwise.
func (*RatchetMessage) GetType ¶
func (obj *RatchetMessage) GetType() MsgType
* Returns message type.
func (*RatchetMessage) Serialize ¶
func (obj *RatchetMessage) Serialize() []byte
* Serializes instance.
func (*RatchetMessage) SerializeLen ¶
func (obj *RatchetMessage) SerializeLen() uint
* Buffer len to serialize this class.
type RatchetSession ¶
type RatchetSession struct {
// contains filtered or unexported fields
}
* Class for ratchet session between 2 participants
func NewRatchetSession ¶
func NewRatchetSession() *RatchetSession
func RatchetSessionDeserialize ¶
func RatchetSessionDeserialize(input []byte) (*RatchetSession, error)
* Deserializes session from buffer. * NOTE: Deserialized session needs dependencies to be set. Check setup defaults
func (*RatchetSession) Decrypt ¶
func (obj *RatchetSession) Decrypt(message *RatchetMessage) ([]byte, error)
* Decrypts message
func (*RatchetSession) DecryptLen ¶
func (obj *RatchetSession) DecryptLen(message *RatchetMessage) uint
* Calculates size of buffer sufficient to store decrypted message
func (*RatchetSession) Encrypt ¶
func (obj *RatchetSession) Encrypt(plainText []byte) (*RatchetMessage, error)
* Encrypts data
func (*RatchetSession) Initiate ¶
func (obj *RatchetSession) Initiate(senderIdentityPrivateKey []byte, receiverIdentityPublicKey []byte, receiverLongTermPublicKey []byte, receiverOneTimePublicKey []byte) error
* Initiates session
func (*RatchetSession) IsInitiator ¶
func (obj *RatchetSession) IsInitiator() bool
* Returns flag that indicates is this session was initiated or responded
func (*RatchetSession) ReceivedFirstResponse ¶
func (obj *RatchetSession) ReceivedFirstResponse() bool
* Returns true if at least 1 response was successfully decrypted, false - otherwise
func (*RatchetSession) ReceiverHasOneTimePublicKey ¶
func (obj *RatchetSession) ReceiverHasOneTimePublicKey() bool
* Returns true if receiver had one time public key
func (*RatchetSession) Respond ¶
func (obj *RatchetSession) Respond(senderIdentityPublicKey []byte, receiverIdentityPrivateKey []byte, receiverLongTermPrivateKey []byte, receiverOneTimePrivateKey []byte, message *RatchetMessage) error
* Responds to session initiation
func (*RatchetSession) Serialize ¶
func (obj *RatchetSession) Serialize() []byte
* Serializes session to buffer
func (*RatchetSession) SetRng ¶
func (obj *RatchetSession) SetRng(rng foundation.Random)
* Random used to generate keys
func (*RatchetSession) SetupDefaults ¶
func (obj *RatchetSession) SetupDefaults() error
* Setups default dependencies: * - RNG: CTR DRBG
Source Files ¶
- context.go
- group_msg_type.go
- helper.go
- msg_type.go
- platform.go
- ratchet_common.go
- ratchet_error.go
- ratchet_group_message.go
- ratchet_group_participants_ids.go
- ratchet_group_participants_info.go
- ratchet_group_session.go
- ratchet_group_ticket.go
- ratchet_implementation.go
- ratchet_key_id.go
- ratchet_message.go
- ratchet_session.go