forked from keybase/go-keybase-chat-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
saltpack.go
280 lines (246 loc) · 8.75 KB
/
saltpack.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
// Auto-generated to Go types using avdl-compiler v1.4.6 (https://github.com/malware-unicorn/node-avdl-compiler)
// Input file: ../client/protocol/avdl/keybase1/saltpack.avdl
package keybase1
import (
"fmt"
)
type AuthenticityType int
const (
AuthenticityType_SIGNED AuthenticityType = 0
AuthenticityType_REPUDIABLE AuthenticityType = 1
AuthenticityType_ANONYMOUS AuthenticityType = 2
)
func (o AuthenticityType) DeepCopy() AuthenticityType { return o }
var AuthenticityTypeMap = map[string]AuthenticityType{
"SIGNED": 0,
"REPUDIABLE": 1,
"ANONYMOUS": 2,
}
var AuthenticityTypeRevMap = map[AuthenticityType]string{
0: "SIGNED",
1: "REPUDIABLE",
2: "ANONYMOUS",
}
func (e AuthenticityType) String() string {
if v, ok := AuthenticityTypeRevMap[e]; ok {
return v
}
return fmt.Sprintf("%v", int(e))
}
type SaltpackEncryptOptions struct {
Recipients []string `codec:"recipients" json:"recipients"`
TeamRecipients []string `codec:"teamRecipients" json:"teamRecipients"`
AuthenticityType AuthenticityType `codec:"authenticityType" json:"authenticityType"`
UseEntityKeys bool `codec:"useEntityKeys" json:"useEntityKeys"`
UseDeviceKeys bool `codec:"useDeviceKeys" json:"useDeviceKeys"`
UsePaperKeys bool `codec:"usePaperKeys" json:"usePaperKeys"`
NoSelfEncrypt bool `codec:"noSelfEncrypt" json:"noSelfEncrypt"`
Binary bool `codec:"binary" json:"binary"`
SaltpackVersion int `codec:"saltpackVersion" json:"saltpackVersion"`
UseKBFSKeysOnlyForTesting bool `codec:"useKBFSKeysOnlyForTesting" json:"useKBFSKeysOnlyForTesting"`
}
func (o SaltpackEncryptOptions) DeepCopy() SaltpackEncryptOptions {
return SaltpackEncryptOptions{
Recipients: (func(x []string) []string {
if x == nil {
return nil
}
ret := make([]string, len(x))
for i, v := range x {
vCopy := v
ret[i] = vCopy
}
return ret
})(o.Recipients),
TeamRecipients: (func(x []string) []string {
if x == nil {
return nil
}
ret := make([]string, len(x))
for i, v := range x {
vCopy := v
ret[i] = vCopy
}
return ret
})(o.TeamRecipients),
AuthenticityType: o.AuthenticityType.DeepCopy(),
UseEntityKeys: o.UseEntityKeys,
UseDeviceKeys: o.UseDeviceKeys,
UsePaperKeys: o.UsePaperKeys,
NoSelfEncrypt: o.NoSelfEncrypt,
Binary: o.Binary,
SaltpackVersion: o.SaltpackVersion,
UseKBFSKeysOnlyForTesting: o.UseKBFSKeysOnlyForTesting,
}
}
type SaltpackDecryptOptions struct {
Interactive bool `codec:"interactive" json:"interactive"`
ForceRemoteCheck bool `codec:"forceRemoteCheck" json:"forceRemoteCheck"`
UsePaperKey bool `codec:"usePaperKey" json:"usePaperKey"`
}
func (o SaltpackDecryptOptions) DeepCopy() SaltpackDecryptOptions {
return SaltpackDecryptOptions{
Interactive: o.Interactive,
ForceRemoteCheck: o.ForceRemoteCheck,
UsePaperKey: o.UsePaperKey,
}
}
type SaltpackSignOptions struct {
Detached bool `codec:"detached" json:"detached"`
Binary bool `codec:"binary" json:"binary"`
SaltpackVersion int `codec:"saltpackVersion" json:"saltpackVersion"`
}
func (o SaltpackSignOptions) DeepCopy() SaltpackSignOptions {
return SaltpackSignOptions{
Detached: o.Detached,
Binary: o.Binary,
SaltpackVersion: o.SaltpackVersion,
}
}
type SaltpackVerifyOptions struct {
SignedBy string `codec:"signedBy" json:"signedBy"`
Signature []byte `codec:"signature" json:"signature"`
}
func (o SaltpackVerifyOptions) DeepCopy() SaltpackVerifyOptions {
return SaltpackVerifyOptions{
SignedBy: o.SignedBy,
Signature: (func(x []byte) []byte {
if x == nil {
return nil
}
return append([]byte{}, x...)
})(o.Signature),
}
}
type SaltpackEncryptResult struct {
UsedUnresolvedSBS bool `codec:"usedUnresolvedSBS" json:"usedUnresolvedSBS"`
UnresolvedSBSAssertion string `codec:"unresolvedSBSAssertion" json:"unresolvedSBSAssertion"`
}
func (o SaltpackEncryptResult) DeepCopy() SaltpackEncryptResult {
return SaltpackEncryptResult{
UsedUnresolvedSBS: o.UsedUnresolvedSBS,
UnresolvedSBSAssertion: o.UnresolvedSBSAssertion,
}
}
type SaltpackEncryptedMessageInfo struct {
Devices []Device `codec:"devices" json:"devices"`
NumAnonReceivers int `codec:"numAnonReceivers" json:"numAnonReceivers"`
ReceiverIsAnon bool `codec:"receiverIsAnon" json:"receiverIsAnon"`
Sender SaltpackSender `codec:"sender" json:"sender"`
}
func (o SaltpackEncryptedMessageInfo) DeepCopy() SaltpackEncryptedMessageInfo {
return SaltpackEncryptedMessageInfo{
Devices: (func(x []Device) []Device {
if x == nil {
return nil
}
ret := make([]Device, len(x))
for i, v := range x {
vCopy := v.DeepCopy()
ret[i] = vCopy
}
return ret
})(o.Devices),
NumAnonReceivers: o.NumAnonReceivers,
ReceiverIsAnon: o.ReceiverIsAnon,
Sender: o.Sender.DeepCopy(),
}
}
type SaltpackFrontendEncryptOptions struct {
Recipients []string `codec:"recipients" json:"recipients"`
Signed bool `codec:"signed" json:"signed"`
IncludeSelf bool `codec:"includeSelf" json:"includeSelf"`
}
func (o SaltpackFrontendEncryptOptions) DeepCopy() SaltpackFrontendEncryptOptions {
return SaltpackFrontendEncryptOptions{
Recipients: (func(x []string) []string {
if x == nil {
return nil
}
ret := make([]string, len(x))
for i, v := range x {
vCopy := v
ret[i] = vCopy
}
return ret
})(o.Recipients),
Signed: o.Signed,
IncludeSelf: o.IncludeSelf,
}
}
type SaltpackEncryptStringResult struct {
UsedUnresolvedSBS bool `codec:"usedUnresolvedSBS" json:"usedUnresolvedSBS"`
UnresolvedSBSAssertion string `codec:"unresolvedSBSAssertion" json:"unresolvedSBSAssertion"`
Ciphertext string `codec:"ciphertext" json:"ciphertext"`
}
func (o SaltpackEncryptStringResult) DeepCopy() SaltpackEncryptStringResult {
return SaltpackEncryptStringResult{
UsedUnresolvedSBS: o.UsedUnresolvedSBS,
UnresolvedSBSAssertion: o.UnresolvedSBSAssertion,
Ciphertext: o.Ciphertext,
}
}
type SaltpackEncryptFileResult struct {
UsedUnresolvedSBS bool `codec:"usedUnresolvedSBS" json:"usedUnresolvedSBS"`
UnresolvedSBSAssertion string `codec:"unresolvedSBSAssertion" json:"unresolvedSBSAssertion"`
Filename string `codec:"filename" json:"filename"`
}
func (o SaltpackEncryptFileResult) DeepCopy() SaltpackEncryptFileResult {
return SaltpackEncryptFileResult{
UsedUnresolvedSBS: o.UsedUnresolvedSBS,
UnresolvedSBSAssertion: o.UnresolvedSBSAssertion,
Filename: o.Filename,
}
}
type SaltpackPlaintextResult struct {
Info SaltpackEncryptedMessageInfo `codec:"info" json:"info"`
Plaintext string `codec:"plaintext" json:"plaintext"`
Signed bool `codec:"signed" json:"signed"`
}
func (o SaltpackPlaintextResult) DeepCopy() SaltpackPlaintextResult {
return SaltpackPlaintextResult{
Info: o.Info.DeepCopy(),
Plaintext: o.Plaintext,
Signed: o.Signed,
}
}
type SaltpackFileResult struct {
Info SaltpackEncryptedMessageInfo `codec:"info" json:"info"`
DecryptedFilename string `codec:"decryptedFilename" json:"decryptedFilename"`
Signed bool `codec:"signed" json:"signed"`
}
func (o SaltpackFileResult) DeepCopy() SaltpackFileResult {
return SaltpackFileResult{
Info: o.Info.DeepCopy(),
DecryptedFilename: o.DecryptedFilename,
Signed: o.Signed,
}
}
type SaltpackVerifyResult struct {
SigningKID KID `codec:"signingKID" json:"signingKID"`
Sender SaltpackSender `codec:"sender" json:"sender"`
Plaintext string `codec:"plaintext" json:"plaintext"`
Verified bool `codec:"verified" json:"verified"`
}
func (o SaltpackVerifyResult) DeepCopy() SaltpackVerifyResult {
return SaltpackVerifyResult{
SigningKID: o.SigningKID.DeepCopy(),
Sender: o.Sender.DeepCopy(),
Plaintext: o.Plaintext,
Verified: o.Verified,
}
}
type SaltpackVerifyFileResult struct {
SigningKID KID `codec:"signingKID" json:"signingKID"`
Sender SaltpackSender `codec:"sender" json:"sender"`
VerifiedFilename string `codec:"verifiedFilename" json:"verifiedFilename"`
Verified bool `codec:"verified" json:"verified"`
}
func (o SaltpackVerifyFileResult) DeepCopy() SaltpackVerifyFileResult {
return SaltpackVerifyFileResult{
SigningKID: o.SigningKID.DeepCopy(),
Sender: o.Sender.DeepCopy(),
VerifiedFilename: o.VerifiedFilename,
Verified: o.Verified,
}
}