Documentation ¶
Overview ¶
account packages an account which stores the identity, one time keys and fallback keys.
Index ¶
- Constants
- type Account
- func (a Account) FallbackKey() map[string]id.Curve25519
- func (a Account) FallbackKeyJSON() ([]byte, error)
- func (a Account) FallbackKeyUnpublished() map[string]id.Curve25519
- func (a Account) FallbackKeyUnpublishedJSON() ([]byte, error)
- func (a *Account) ForgetOldFallbackKey()
- func (a *Account) GenFallbackKey(reader io.Reader) error
- func (a *Account) GenOneTimeKeys(reader io.Reader, num uint) error
- func (a Account) IdentityKeys() (id.Ed25519, id.Curve25519)
- func (a Account) IdentityKeysJSON() ([]byte, error)
- func (a *Account) MarkKeysAsPublished()
- func (a Account) NewInboundSession(theirIdentityKey *id.Curve25519, oneTimeKeyMsg []byte) (*session.OlmSession, error)
- func (a Account) NewOutboundSession(theirIdentityKey, theirOneTimeKey id.Curve25519) (*session.OlmSession, error)
- func (a Account) OneTimeKeys() map[string]id.Curve25519
- func (a Account) OneTimeKeysJSON() ([]byte, error)
- func (a Account) Pickle(key []byte) ([]byte, error)
- func (a Account) PickleAsJSON(key []byte) ([]byte, error)
- func (a Account) PickleLen() int
- func (a Account) PickleLibOlm(target []byte) (int, error)
- func (a *Account) RemoveOneTimeKeys(s *session.OlmSession)
- func (a Account) Sign(message []byte) ([]byte, error)
- func (a *Account) Unpickle(pickled, key []byte) error
- func (a *Account) UnpickleAsJSON(pickled, key []byte) error
- func (a *Account) UnpickleLibOlm(value []byte) (int, error)
Constants ¶
const (
MaxOneTimeKeys int = 100 //maximum number of stored one time keys per Account
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { IdKeys struct { Ed25519 crypto.Ed25519KeyPair `json:"ed25519,omitempty"` Curve25519 crypto.Curve25519KeyPair `json:"curve25519,omitempty"` } `json:"identity_keys"` OTKeys []crypto.OneTimeKey `json:"one_time_keys"` CurrentFallbackKey crypto.OneTimeKey `json:"current_fallback_key,omitempty"` PrevFallbackKey crypto.OneTimeKey `json:"prev_fallback_key,omitempty"` NextOneTimeKeyID uint32 `json:"next_one_time_key_id,omitempty"` NumFallbackKeys uint8 `json:"number_fallback_keys"` }
Account stores an account for end to end encrypted messaging via the olm protocol. An Account can not be used to en/decrypt messages. However it can be used to contruct new olm sessions, which in turn do the en/decryption. There is no tracking of sessions in an account.
func AccountFromJSONPickled ¶
AccountFromJSONPickled loads the Account details from a pickled base64 string. The input is decrypted with the supplied key.
func AccountFromPickled ¶
AccountFromPickled loads the Account details from a pickled base64 string. The input is decrypted with the supplied key.
func NewAccount ¶
NewAccount creates a new Account. If reader is nil, crypto/rand is used for the key creation.
func (Account) FallbackKey ¶
func (a Account) FallbackKey() map[string]id.Curve25519
FallbackKey returns the public part of the current fallback key of the Account. The returned data is a map with the mapping of key id to base64-encoded Curve25519 key.
func (Account) FallbackKeyJSON ¶
FallbackKeyJSON returns the public part of the current fallback key of the Account as a JSON string.
The returned JSON is of format:
{ curve25519: { "AAAAAA": "wo76WcYtb0Vk/pBOdmduiGJ0wIEjW4IBMbbQn7aSnTo" } }
func (Account) FallbackKeyUnpublished ¶
func (a Account) FallbackKeyUnpublished() map[string]id.Curve25519
FallbackKeyUnpublished returns the public part of the current fallback key of the Account only if it is unpublished. The returned data is a map with the mapping of key id to base64-encoded Curve25519 key.
func (Account) FallbackKeyUnpublishedJSON ¶
FallbackKeyUnpublishedJSON returns the public part of the current fallback key, only if it is unpublished, of the Account as a JSON string.
The returned JSON is of format:
{ curve25519: { "AAAAAA": "wo76WcYtb0Vk/pBOdmduiGJ0wIEjW4IBMbbQn7aSnTo" } }
func (*Account) ForgetOldFallbackKey ¶
func (a *Account) ForgetOldFallbackKey()
ForgetOldFallbackKey resets the previous fallback key in the account.
func (*Account) GenFallbackKey ¶
GenFallbackKey generates a new fallback key. The old fallback key is stored in a.PrevFallbackKey overwriting any previous PrevFallbackKey. If reader is nil, crypto/rand is used for the key creation.
func (*Account) GenOneTimeKeys ¶
GenOneTimeKeys generates a number of new one time keys. If the total number of keys stored by this Account exceeds MaxOneTimeKeys then the older keys are discarded. If reader is nil, crypto/rand is used for the key creation.
func (Account) IdentityKeys ¶
func (a Account) IdentityKeys() (id.Ed25519, id.Curve25519)
IdentityKeys returns the public parts of the Ed25519 and Curve25519 identity keys for the Account.
func (Account) IdentityKeysJSON ¶
IdentityKeysJSON returns the public parts of the identity keys for the Account in a JSON string.
func (*Account) MarkKeysAsPublished ¶
func (a *Account) MarkKeysAsPublished()
MarkKeysAsPublished marks the current set of one time keys and the fallback key as being published.
func (Account) NewInboundSession ¶
func (a Account) NewInboundSession(theirIdentityKey *id.Curve25519, oneTimeKeyMsg []byte) (*session.OlmSession, error)
NewInboundSession creates a new inbound session from an incoming PRE_KEY message.
func (Account) NewOutboundSession ¶
func (a Account) NewOutboundSession(theirIdentityKey, theirOneTimeKey id.Curve25519) (*session.OlmSession, error)
NewOutboundSession creates a new outbound session to a given curve25519 identity Key and one time key.
func (Account) OneTimeKeys ¶
func (a Account) OneTimeKeys() map[string]id.Curve25519
OneTimeKeys returns the public parts of the unpublished one time keys of the Account.
The returned data is a map with the mapping of key id to base64-encoded Curve25519 key.
func (Account) OneTimeKeysJSON ¶
OneTimeKeysJSON returns the public parts of the unpublished one time keys of the Account as a JSON string.
The returned JSON is of format:
{ Curve25519: { "AAAAAA": "wo76WcYtb0Vk/pBOdmduiGJ0wIEjW4IBMbbQn7aSnTo", "AAAAAB": "LRvjo46L1X2vx69sS9QNFD29HWulxrmW11Up5AfAjgU" } }
func (Account) Pickle ¶
Pickle returns a base64 encoded and with key encrypted pickled account using PickleLibOlm().
func (Account) PickleAsJSON ¶
PickleAsJSON returns an Account as a base64 string encrypted using the supplied key. The unencrypted representation of the Account is in JSON format.
func (Account) PickleLibOlm ¶
PickleLibOlm encodes the Account into target. target has to have a size of at least PickleLen() and is written to from index 0. It returns the number of bytes written.
func (*Account) RemoveOneTimeKeys ¶
func (a *Account) RemoveOneTimeKeys(s *session.OlmSession)
RemoveOneTimeKeys removes the one time key in this Account which matches the one time key in the session s.
func (Account) Sign ¶
Sign returns the base64-encoded signature of a message using the Ed25519 key for this Account.
func (*Account) Unpickle ¶
Unpickle decodes the base64 encoded string and decrypts the result with the key. The decrypted value is then passed to UnpickleLibOlm.
func (*Account) UnpickleAsJSON ¶
UnpickleAsJSON updates an Account by a base64 encrypted string using the supplied key. The unencrypted representation has to be in JSON format.