Documentation ¶
Index ¶
- Constants
- func CreateKey(password string, salt []byte) [32]byte
- func CreateKeySalt(password string) ([32]byte, [128]byte, error)
- func DecryptFile(ciphertext []byte, key [32]byte) ([]byte, error)
- func EncryptFileData(data []byte, key [32]byte) ([]byte, error)
- func GenerateRandomID() string
- func InitV1Directory(directory, password string) ([32]byte, [128]byte, error)
- func ReadEncryptedFile(directory, filename string, key [32]byte) ([]byte, error)
- type FileStore
- type MessageStoreInterface
- type SqliteMessageStore
- func (s *SqliteMessageStore) AddMessage(message groups.EncryptedGroupMessage)
- func (s *SqliteMessageStore) Close()
- func (s *SqliteMessageStore) FetchMessages() []*groups.EncryptedGroupMessage
- func (s *SqliteMessageStore) FetchMessagesFrom(signature []byte) []*groups.EncryptedGroupMessage
- func (s *SqliteMessageStore) MessagesCount() int
- func (s *SqliteMessageStore) SetMessageCap(newcap int)
Constants ¶
const SaltFile = "SALT"
SaltFile is the standard filename to store an encrypted config's SALT under beside it
Variables ¶
This section is empty.
Functions ¶
func CreateKeySalt ¶
CreateKeySalt derives a key and salt from a password: returns key, salt, err
func DecryptFile ¶
DecryptFile decrypts the passed ciphertext with the supplied key.
func EncryptFileData ¶
EncryptFileData encrypts the data with the supplied key
func GenerateRandomID ¶
func GenerateRandomID() string
GenerateRandomID generates a random 16 byte hex id code
func InitV1Directory ¶
InitV1Directory generates a key and salt from a password, writes a SALT and VERSION file and returns the key and salt
Types ¶
type FileStore ¶
type FileStore interface { Write([]byte) error Read() ([]byte, error) Delete() ChangeKey(newkey [32]byte) }
FileStore is a primitive around storing encrypted files
type MessageStoreInterface ¶
type MessageStoreInterface interface { AddMessage(groups.EncryptedGroupMessage) FetchMessages() []*groups.EncryptedGroupMessage MessagesCount() int FetchMessagesFrom(signature []byte) []*groups.EncryptedGroupMessage SetMessageCap(newcap int) Close() }
MessageStoreInterface defines an interface to interact with a store of cwtch messages.
type SqliteMessageStore ¶
type SqliteMessageStore struct {
// contains filtered or unexported fields
}
SqliteMessageStore is an sqlite3 backed message store
func InitializeSqliteMessageStore ¶
func InitializeSqliteMessageStore(dbfile string, messageCap int, incMessageCounterFn func()) (*SqliteMessageStore, error)
InitializeSqliteMessageStore creates a database `dbfile` with the necessary tables (if it doesn't already exist) and returns an open database
func (*SqliteMessageStore) AddMessage ¶
func (s *SqliteMessageStore) AddMessage(message groups.EncryptedGroupMessage)
AddMessage implements the MessageStoreInterface AddMessage for sqlite message store
func (*SqliteMessageStore) Close ¶
func (s *SqliteMessageStore) Close()
Close closes the underlying sqlite3 database to further changes
func (*SqliteMessageStore) FetchMessages ¶
func (s *SqliteMessageStore) FetchMessages() []*groups.EncryptedGroupMessage
FetchMessages implements the MessageStoreInterface FetchMessages for sqlite message store
func (*SqliteMessageStore) FetchMessagesFrom ¶
func (s *SqliteMessageStore) FetchMessagesFrom(signature []byte) []*groups.EncryptedGroupMessage
FetchMessagesFrom implements the MessageStoreInterface FetchMessagesFrom for sqlite message store
func (*SqliteMessageStore) MessagesCount ¶
func (s *SqliteMessageStore) MessagesCount() int
func (*SqliteMessageStore) SetMessageCap ¶
func (s *SqliteMessageStore) SetMessageCap(newcap int)