Example #1
0
// Create returns a new KEY database with the given dbname.
// It is encrypted by passphrase (processed by a KDF with iter many iterations).
func Create(dbname string, passphrase []byte, iter int) error {
	err := encdb.Create(dbname, passphrase, iter, []string{
		createQueryKeyValue,
		createQueryPrivateUIDs,
		createQueryPublicUIDs,
		createQueryPrivateKeyInits,
		createQueryPublicKeyInits,
		createQuerySessions,
		createQueryMessageKeys,
		createQueryHashchains,
		createQuerySessionStates,
		createQuerySessionKeys,
	})
	if err != nil {
		return err
	}
	keyDB, err := Open(dbname, passphrase)
	if err != nil {
		return err
	}
	defer keyDB.Close()
	if err := keyDB.AddValue(DBVersion, Version); err != nil {
		return err
	}
	return nil
}
Example #2
0
// Create returns a new message database with the given dbname.
// It is encrypted by passphrase (processed by a KDF with iter many iterations).
func Create(dbname string, passphrase []byte, iter int) error {
	err := encdb.Create(dbname, passphrase, iter, []string{
		createQueryKeyValue,
		createQueryNyms,
		createQueryContacts,
		createQueryAccounts,
		createQueryMessages,
		createQueryAttachments,
		createQueryChunks,
		createQueryOutQueue,
		createQueryInQueue,
		createMessageIDCache,
	})
	if err != nil {
		return err
	}
	msgDB, err := Open(dbname, passphrase)
	if err != nil {
		return err
	}
	defer msgDB.Close()
	if err := msgDB.AddValue(DBVersion, Version); err != nil {
		return err
	}
	return nil
}