/
properties.go
49 lines (39 loc) · 1.09 KB
/
properties.go
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
package v1
import (
"crypto/aes"
"crypto/sha512"
)
// Below is a representation of the finished data that will be written to the io.Writer passed into NewEnc:
// Data:
// Version|Argon2Version|CostTime|CostMemory|CostThreads|Salt|IV|EncryptedData|HMACSignature
// Bytes:
// 2|2|4|4|1|64|16|variable|64
const (
Version uint16 = 1
FileExt = "lkd"
//lengths of the ciphers used for encryption and verification
keyLenCipher = 32 //keysize for AES-256 cipher block
keyLenHash = 64
//default cost params
defCostTime = 4
defCostMem = 1024 * 512 //512 MB, the argon2 memory arg is in KB
defCostThread = 8
//header data length
lenVer = 2
lenVerArgon = 2
lenSalt = 64
lenIV = aes.BlockSize
//time cost data length
lenCostTime = 4
lenCostMem = 4
lenCostThread = 1
//signature length
lenSig = sha512.Size
//combined lengths
lenCostParams = lenCostTime + lenCostMem + lenCostThread
lenHeader = lenVer + lenVerArgon + lenSalt + lenIV + lenCostParams
lenTotalAdded = lenHeader + lenSig
//exported lengths
LenHeader = lenHeader
LenSig = lenSig
)