File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,9 @@ func newAuthEncV10(cfg *Config) (authEncV10, error) {
90
90
return authEncV10 {}, err
91
91
}
92
92
var randVal [8 ]byte
93
- if _ , err = io .ReadFull (cfg .Rand , randVal [:]); err != nil {
93
+ if cfg .Nonce != nil {
94
+ copy (randVal [:], cfg .Nonce [:8 ])
95
+ } else if _ , err = io .ReadFull (cfg .Rand , randVal [:]); err != nil {
94
96
return authEncV10 {}, err
95
97
}
96
98
return authEncV10 {
@@ -167,7 +169,9 @@ func newAuthEncV20(cfg *Config) (authEncV20, error) {
167
169
return authEncV20 {}, err
168
170
}
169
171
var randVal [12 ]byte
170
- if _ , err = io .ReadFull (cfg .Rand , randVal [:]); err != nil {
172
+ if cfg .Nonce != nil {
173
+ randVal = * cfg .Nonce
174
+ } else if _ , err = io .ReadFull (cfg .Rand , randVal [:]); err != nil {
171
175
return authEncV20 {}, err
172
176
}
173
177
return authEncV20 {
Original file line number Diff line number Diff line change @@ -122,6 +122,10 @@ type Config struct {
122
122
// the default value (crypto/rand.Reader) is used.
123
123
Rand io.Reader
124
124
125
+ // Nonce will override the nonce if set non-nil.
126
+ // V2 will use all 12 bytes, V1 first 8 bytes.
127
+ Nonce * [12 ]byte
128
+
125
129
// The size of the encrypted payload in bytes. The
126
130
// default value is 64KB. It should be used to restrict
127
131
// the size of encrypted packages. The payload size
You can’t perform that action at this time.
0 commit comments