-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrsa_encrypt_opts.go
97 lines (79 loc) · 1.85 KB
/
rsa_encrypt_opts.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
package criptus
type RSAOptions func(*RSAParams) error
type RSAParams struct {
rsaBitsType RsaBitsType
publishKeyName string
privateKeyName string
publishKeyPath string
privateKeyPath string
}
func newRSAParams(opts ...RSAOptions) (*RSAParams, error) {
options := &RSAParams{}
for _, opt := range opts {
err := opt(options)
if err != nil {
return &RSAParams{}, err
}
}
return options, nil
}
func RSAWithType(kind RsaBitsType) RSAOptions {
return func(params *RSAParams) error {
params.rsaBitsType = kind
return nil
}
}
func RSAWithPublishKeyName(name string) RSAOptions {
return func(params *RSAParams) error {
params.publishKeyName = name
return nil
}
}
func RSAWithPublishKeyPath(path string) RSAOptions {
return func(params *RSAParams) error {
params.publishKeyPath = path
return nil
}
}
func RSAWithPrivateKeyName(name string) RSAOptions {
return func(params *RSAParams) error {
params.privateKeyName = name
return nil
}
}
func RSAWithPrivateKeyPath(path string) RSAOptions {
return func(params *RSAParams) error {
params.privateKeyPath = path
return nil
}
}
func (p RSAParams) GetBits() RsaBitsType {
return p.rsaBitsType
}
func (p RSAParams) GetPublishKeyName() string {
return p.publishKeyName
}
func (p RSAParams) GetPublishKeyPath() string {
return p.publishKeyPath
}
func (p RSAParams) GetPrivateKeyName() string {
return p.privateKeyName
}
func (p RSAParams) GetPrivateKeyPath() string {
return p.privateKeyPath
}
func (p *RSAParams) SetBits(bits RsaBitsType) {
p.rsaBitsType = bits
}
func (p *RSAParams) SetPublishKeyName(name string) {
p.publishKeyName = name
}
func (p *RSAParams) SetPublishKeyPath(path string) {
p.publishKeyPath = path
}
func (p *RSAParams) SetPrivateKeyName(name string) {
p.privateKeyName = name
}
func (p *RSAParams) SetPrivateKeyPath(path string) {
p.privateKeyPath = path
}