-
Notifications
You must be signed in to change notification settings - Fork 2
/
v2json.go
157 lines (132 loc) · 4.91 KB
/
v2json.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
package luksy
type V2JSON struct {
Config V2JSONConfig `json:"config"`
Keyslots map[string]V2JSONKeyslot `json:"keyslots"`
Digests map[string]V2JSONDigest `json:"digests"`
Segments map[string]V2JSONSegment `json:"segments"`
Tokens map[string]V2JSONToken `json:"tokens"`
}
type V2JSONKeyslotPriority int
func (p V2JSONKeyslotPriority) String() string {
switch p {
case V2JSONKeyslotPriorityIgnore:
return "ignore"
case V2JSONKeyslotPriorityNormal:
return "normal"
case V2JSONKeyslotPriorityHigh:
return "high"
}
return "unknown"
}
const (
V2JSONKeyslotPriorityIgnore = V2JSONKeyslotPriority(0)
V2JSONKeyslotPriorityNormal = V2JSONKeyslotPriority(1)
V2JSONKeyslotPriorityHigh = V2JSONKeyslotPriority(2)
)
type V2JSONKeyslot struct {
Type string `json:"type"`
KeySize int `json:"key_size"`
Area V2JSONArea `json:"area"`
Priority *V2JSONKeyslotPriority `json:"priority,omitempty"`
*V2JSONKeyslotLUKS2 // type = "luks2"
*V2JSONKeyslotReencrypt // type = "reencrypt"
}
type V2JSONKeyslotLUKS2 struct {
AF V2JSONAF `json:"af"`
Kdf V2JSONKdf `json:"kdf"`
}
type V2JSONKeyslotReencrypt struct {
Mode string `json:"mode"` // only "reencrypt", "encrypt", "decrypt"
Direction string `json:"direction"` // only "forward", "backward"
}
type V2JSONArea struct {
Type string `json:"type"` // only "raw", "none", "journal", "checksum", "datashift", "datashift-journal", "datashift-checksum"
Offset int64 `json:"offset,string"`
Size int64 `json:"size,string"`
*V2JSONAreaRaw // type = "raw"
*V2JSONAreaChecksum // type = "checksum"
*V2JSONAreaDatashift // type = "datashift"
*V2JSONAreaDatashiftChecksum // type = "datashift-checksum"
}
type V2JSONAreaRaw struct {
Encryption string `json:"encryption"`
KeySize int `json:"key_size"`
}
type V2JSONAreaChecksum struct {
Hash string `json:"hash"`
SectorSize int `json:"sector_size"`
}
type V2JSONAreaDatashift struct {
ShiftSize int `json:"shift_size,string"`
}
type V2JSONAreaDatashiftChecksum struct {
V2JSONAreaChecksum
V2JSONAreaDatashift
}
type V2JSONAF struct {
Type string `json:"type"` // "luks1"
*V2JSONAFLUKS1 // type == "luks1"
}
type V2JSONAFLUKS1 struct {
Stripes int `json:"stripes"` // 4000
Hash string `json:"hash"` // "sha256"
}
type V2JSONKdf struct {
Type string `json:"type"`
Salt []byte `json:"salt"`
*V2JSONKdfPbkdf2 // type = "pbkdf2"
*V2JSONKdfArgon2i // type = "argon2i" or type = "argon2id"
}
type V2JSONKdfPbkdf2 struct {
Hash string `json:"hash"`
Iterations int `json:"iterations"`
}
type V2JSONKdfArgon2i struct {
Time int `json:"time"`
Memory int `json:"memory"`
CPUs int `json:"cpus"`
}
type V2JSONSegment struct {
Type string `json:"type"` // only "linear", "crypt"
Offset string `json:"offset"`
Size string `json:"size"` // numeric value or "dynamic"
Flags []string `json:"flags,omitempty"`
*V2JSONSegmentCrypt `json:",omitempty"` // type = "crypt"
}
type V2JSONSegmentCrypt struct {
IVTweak int `json:"iv_tweak,string"`
Encryption string `json:"encryption"`
SectorSize int `json:"sector_size"` // 512 or 1024 or 2048 or 4096
Integrity *V2JSONSegmentIntegrity `json:"integrity,omitempty"`
}
type V2JSONSegmentIntegrity struct {
Type string `json:"type"`
JournalEncryption string `json:"journal_encryption"`
JournalIntegrity string `json:"journal_integrity"`
}
type V2JSONDigest struct {
Type string `json:"type"`
Keyslots []string `json:"keyslots"`
Segments []string `json:"segments"`
Salt []byte `json:"salt"`
Digest []byte `json:"digest"`
*V2JSONDigestPbkdf2 // type == "pbkdf2"
}
type V2JSONDigestPbkdf2 struct {
Hash string `json:"hash"`
Iterations int `json:"iterations"`
}
type V2JSONConfig struct {
JsonSize int `json:"json_size,string"`
KeyslotsSize int `json:"keyslots_size,string,omitempty"`
Flags []string `json:"flags,omitempty"` // one or more of "allow-discards", "same-cpu-crypt", "submit-from-crypt-cpus", "no-journal", "no-read-workqueue", "no-write-workqueue"
Requirements []string `json:"requirements,omitempty"`
}
type V2JSONToken struct {
Type string `json:"type"` // "luks2-keyring"
Keyslots []string `json:"keyslots,omitempty"`
*V2JSONTokenLUKS2Keyring // type == "luks2-keyring"
}
type V2JSONTokenLUKS2Keyring struct {
KeyDescription string `json:"key_description"`
}