diff options
Diffstat (limited to 'vendor/golang.org/x/crypto/bcrypt/bcrypt.go')
-rw-r--r-- | vendor/golang.org/x/crypto/bcrypt/bcrypt.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/vendor/golang.org/x/crypto/bcrypt/bcrypt.go b/vendor/golang.org/x/crypto/bcrypt/bcrypt.go index f8b807f..aeb73f8 100644 --- a/vendor/golang.org/x/crypto/bcrypt/bcrypt.go +++ b/vendor/golang.org/x/crypto/bcrypt/bcrypt.go | |||
@@ -12,9 +12,10 @@ import ( | |||
12 | "crypto/subtle" | 12 | "crypto/subtle" |
13 | "errors" | 13 | "errors" |
14 | "fmt" | 14 | "fmt" |
15 | "golang.org/x/crypto/blowfish" | ||
16 | "io" | 15 | "io" |
17 | "strconv" | 16 | "strconv" |
17 | |||
18 | "golang.org/x/crypto/blowfish" | ||
18 | ) | 19 | ) |
19 | 20 | ||
20 | const ( | 21 | const ( |
@@ -205,7 +206,6 @@ func bcrypt(password []byte, cost int, salt []byte) ([]byte, error) { | |||
205 | } | 206 | } |
206 | 207 | ||
207 | func expensiveBlowfishSetup(key []byte, cost uint32, salt []byte) (*blowfish.Cipher, error) { | 208 | func expensiveBlowfishSetup(key []byte, cost uint32, salt []byte) (*blowfish.Cipher, error) { |
208 | |||
209 | csalt, err := base64Decode(salt) | 209 | csalt, err := base64Decode(salt) |
210 | if err != nil { | 210 | if err != nil { |
211 | return nil, err | 211 | return nil, err |
@@ -213,7 +213,8 @@ func expensiveBlowfishSetup(key []byte, cost uint32, salt []byte) (*blowfish.Cip | |||
213 | 213 | ||
214 | // Bug compatibility with C bcrypt implementations. They use the trailing | 214 | // Bug compatibility with C bcrypt implementations. They use the trailing |
215 | // NULL in the key string during expansion. | 215 | // NULL in the key string during expansion. |
216 | ckey := append(key, 0) | 216 | // We copy the key to prevent changing the underlying array. |
217 | ckey := append(key[:len(key):len(key)], 0) | ||
217 | 218 | ||
218 | c, err := blowfish.NewSaltedCipher(ckey, csalt) | 219 | c, err := blowfish.NewSaltedCipher(ckey, csalt) |
219 | if err != nil { | 220 | if err != nil { |
@@ -240,11 +241,11 @@ func (p *hashed) Hash() []byte { | |||
240 | n = 3 | 241 | n = 3 |
241 | } | 242 | } |
242 | arr[n] = '$' | 243 | arr[n] = '$' |
243 | n += 1 | 244 | n++ |
244 | copy(arr[n:], []byte(fmt.Sprintf("%02d", p.cost))) | 245 | copy(arr[n:], []byte(fmt.Sprintf("%02d", p.cost))) |
245 | n += 2 | 246 | n += 2 |
246 | arr[n] = '$' | 247 | arr[n] = '$' |
247 | n += 1 | 248 | n++ |
248 | copy(arr[n:], p.salt) | 249 | copy(arr[n:], p.salt) |
249 | n += encodedSaltSize | 250 | n += encodedSaltSize |
250 | copy(arr[n:], p.hash) | 251 | copy(arr[n:], p.hash) |