-
Notifications
You must be signed in to change notification settings - Fork 24
/
with.go
70 lines (53 loc) · 1.22 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
65
66
67
68
69
70
package ecdh
import (
"github.com/deatil/go-cryptobin/dh/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 | P224]
func (this Ecdh) SetCurve(name string) Ecdh {
var curve ecdh.Curve
switch name {
case "P521":
curve = ecdh.P521()
case "P384":
curve = ecdh.P384()
case "P256":
curve = ecdh.P256()
case "P224":
curve = ecdh.P224()
default:
curve = ecdh.P224()
}
this.curve = curve
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
}