cryptostore

package
v0.0.0-...-3ee71c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2014 License: Apache-2.0 Imports: 13 Imported by: 0

README

Crypter

Goal

Store encrypted BLOBs of data for multiple users on a server. New users can be added by all existing users, BLOBs can be changed by all users.

Create user

  • All user data is stored in a user specific directory $ROOT/users/<login>
  • Creating of users requires the login name and a user specific password
  • A new 4096 bit RSA keypair is created, the public key is stored unencrypted, the privat key is encrypted with AES and the provided password

Store BLOB for a specific user

  • a new 32 byte secret AES key is created
  • the BLOB is encrypted and stored with the generated key `$ROOT/users//data.
  • the generated key is encrypted with the public key of the user

Read BLOB by user

  • the private RSA key of the user is decrypted by the user provided password
  • the secret key of the BLOB is decrypted with private RSA key
  • the BLOB es decrypted withg the secret key

Approach

All users have secret 32 byte keys which are provided with each request.

Requirements

All stored BLOBs need to have some version (or checksum) in their names.

Documentation

Index

Constants

View Source
const DefaultBits = 4096

Variables

This section is empty.

Functions

func GenerateRandomKey

func GenerateRandomKey() []byte

Types

type Crypter

type Crypter struct {
	Secret string
}

func NewCrypter

func NewCrypter(secret string) *Crypter

func (*Crypter) Cipher

func (crypter *Crypter) Cipher() (c cipher.Block, e error)

func (*Crypter) Decrypt

func (crypter *Crypter) Decrypt(ciphertext []byte) (s string, e error)

func (*Crypter) Encrypt

func (crypter *Crypter) Encrypt(plaintext []byte) (b []byte, e error)

func (*Crypter) Key

func (crypter *Crypter) Key() []byte

type Store

type Store struct {
	Root string
}

func NewStore

func NewStore(root string) *Store

func (*Store) CreateUser

func (store *Store) CreateUser(login, password string) (u *User, e error)

func (*Store) CreateUserWithBits

func (store *Store) CreateUserWithBits(login, password string, bits int) (u *User, e error)

password needs to have a valid length

func (*Store) LoadPublicKeyForUser

func (store *Store) LoadPublicKeyForUser(login string) (key *rsa.PublicKey, e error)

func (*Store) Read

func (store *Store) Read(login string, secret string) (b []byte, e error)

func (*Store) Store

func (store *Store) Store(blob []byte, login string) error

func (*Store) StoreFileForUser

func (store *Store) StoreFileForUser(login, name string, payload []byte, options *StoreOptions) (e error)

func (*Store) UserExist

func (store *Store) UserExist(login string) bool

func (*Store) UserPath

func (store *Store) UserPath(login string) string

func (*Store) Users

func (store *Store) Users() (users []*User, e error)

type StoreOptions

type StoreOptions struct {
	Encrypt bool
	Encode  bool
}

type User

type User struct {
	Login string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL