-
Notifications
You must be signed in to change notification settings - Fork 25
/
with.go
64 lines (49 loc) · 1.12 KB
/
with.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
package ecdh
import (
"crypto/ecdh"
)
// 设置 PrivateKey
func (this Ecdh) WithPrivateKey(data *ecdh.PrivateKey) Ecdh {
this.privateKey = data
return this
}
// 设置 PublicKey
func (this Ecdh) WithPublicKey(data *ecdh.PublicKey) Ecdh {
this.publicKey = data
return this
}
// 设置散列方式
func (this Ecdh) WithCurve(data ecdh.Curve) Ecdh {
this.curve = data
return this
}
// 设置散列方式
// 可用参数 [P521 | P384 | P256 | X25519]
func (this Ecdh) SetCurve(name string) Ecdh {
switch name {
case "P521":
this.curve = ecdh.P521()
case "P384":
this.curve = ecdh.P384()
case "P256":
this.curve = ecdh.P256()
case "X25519":
this.curve = ecdh.X25519()
}
return this
}
// 设置 keyData
func (this Ecdh) WithKeyData(data []byte) Ecdh {
this.keyData = data
return this
}
// 设置 secretData
func (this Ecdh) WithSecretData(data []byte) Ecdh {
this.secretData = data
return this
}
// 设置错误
func (this Ecdh) WithErrors(errs []error) Ecdh {
this.Errors = errs
return this
}