aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/golang.org/x/crypto/bcrypt/bcrypt.go
diff options
context:
space:
mode:
authorappilon <apilon@hashicorp.com>2019-02-27 16:43:31 -0500
committerGitHub <noreply@github.com>2019-02-27 16:43:31 -0500
commit844b5a68d8af4791755b8f0ad293cc99f5959183 (patch)
tree255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/golang.org/x/crypto/bcrypt/bcrypt.go
parent303b299eeb6b06e939e35905e4b34cb410dd9dc3 (diff)
parent15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (diff)
downloadterraform-provider-statuscake-844b5a68d8af4791755b8f0ad293cc99f5959183.tar.gz
terraform-provider-statuscake-844b5a68d8af4791755b8f0ad293cc99f5959183.tar.zst
terraform-provider-statuscake-844b5a68d8af4791755b8f0ad293cc99f5959183.zip
Merge pull request #27 from terraform-providers/go-modules-2019-02-22
[MODULES] Switch to Go Modules
Diffstat (limited to 'vendor/golang.org/x/crypto/bcrypt/bcrypt.go')
-rw-r--r--vendor/golang.org/x/crypto/bcrypt/bcrypt.go11
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
20const ( 21const (
@@ -205,7 +206,6 @@ func bcrypt(password []byte, cost int, salt []byte) ([]byte, error) {
205} 206}
206 207
207func expensiveBlowfishSetup(key []byte, cost uint32, salt []byte) (*blowfish.Cipher, error) { 208func 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)