-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathdocs.txt
72 lines (48 loc) · 2.75 KB
/
docs.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
PACKAGE DOCUMENTATION
package minilock
import "github.com/cathalgarvey/go-minilock"
VARIABLES
var (
MagicBytesError = errors.New("Magic bytes didn't match expected 'miniLock'.")
BadLengthPrefixError = errors.New("Header length exceeds file length.")
CTHashMismatchError = errors.New("Ciphertext hash did not match.")
BadRecipientError = errors.New("DecryptInfo successfully decrypted but was addressed to another key! (WTF?)")
CannotDecryptError = errors.New("Could not decrypt given ciphertext with given key or nonce.")
NotEnoughRandomnessError = errors.New("Got insufficient random bytes from RNG.")
)
FUNCTIONS
func DecryptFileContents(file_contents []byte, recipientKey *taber.Keys) (senderID, filename string, contents []byte, err error)
func EncryptDecryptInfo(di *DecryptInfoEntry, nonce []byte, ephemKey, recipientKey *taber.Keys) ([]byte, error)
Encrypt a decryptInfo struct using the ephemeral pubkey and the same
nonce as the enclosed fileInfo.
func EncryptFile(filename string, fileContents []byte, sender *taber.Keys, recipients ...*taber.Keys) (miniLockContents []byte, err error)
func EphemeralKey() (*taber.Keys, error)
func GenerateKey(email string, passphrase string) (*taber.Keys, error)
func ParseFile(filepath string) (header *miniLockv1Header, ciphertext []byte, err error)
Opens file and passes to ParseFileContents
func ParseFileContents(contents []byte) (header *miniLockv1Header, ciphertext []byte, err error)
TYPES
type DecryptInfoEntry struct {
SenderID string `json:"senderID"`
RecipientID string `json:"recipientID"`
FileInfoEnc []byte `json:"fileInfo"`
}
func DecryptDecryptInfo(di_enc, nonce []byte, ephemPubkey, recipientKey *taber.Keys) (*DecryptInfoEntry, error)
func NewDecryptInfoEntry(nonce []byte, fileinfo *FileInfo, senderKey, recipientKey *taber.Keys) (*DecryptInfoEntry, error)
func (self *DecryptInfoEntry) ExtractFileInfo(nonce []byte, recipientKey *taber.Keys) (*FileInfo, error)
func (self *DecryptInfoEntry) SenderPubkey() (*taber.Keys, error)
type FileInfo struct {
FileKey []byte `json:"fileKey"`
FileNonce []byte `json:"fileNonce"`
FileHash []byte `json:"fileHash"`
}
func EncryptFileToFileInfo(filename string, filecontents []byte) (FI *FileInfo, ciphertext []byte, err error)
Encrypt a file symmetrically and return a FileInfo object for it.
func (self *FileInfo) DecryptFile(ciphertext []byte) (filename string, contents []byte, err error)
Given a ciphertext, walk it into length prefixed chunks and
decrypt/reassemble each chunk, then validate the hash of the file
against the hash given in FileInfo. The result is a validated, decrypted
filename and file contents byte-slice.
SUBDIRECTORIES
binary_samples
taber