Skip to content

Commit

Permalink
Revert bcrypto.GenerateFromPassword() to mainline go x/crypto
Browse files Browse the repository at this point in the history
As per tendermint#3027.
This change is required for go dep -> go mod migration.
  • Loading branch information
alessio committed Mar 14, 2019
1 parent 48b6b38 commit 7058917
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
5 changes: 2 additions & 3 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
name = "github.com/btcsuite/btcd"
revision = "ed77733ec07dfc8a513741138419b8d9d3de9d2d"

[[override]]
name = "golang.org/x/crypto"
source = "https://github.com/tendermint/crypto"
revision = "3764759f34a542a3aef74d6b02e35be7ab893bba"

[[constraint]]
name = "github.com/cosmos/go-bip39"
revision = "52158e4697b87de16ed390e1bdaf813e581008fa"
Expand All @@ -77,6 +72,10 @@
name = "github.com/syndtr/goleveldb"
revision = "c4c61651e9e37fa117f53c5a906d3b63090d8445"

[[override]]
name = "github.com/x/crypto"
revision = "505ab145d0a99da450461ae2c1a9f6cd10d1f447"

[[override]]
name = "golang.org/x/sys"
revision = "4e1fef5609515ec7a2cee7b5de30ba6d9b438cbf"
Expand Down
6 changes: 3 additions & 3 deletions crypto/keys/mintkey/mintkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/armor"
"github.com/tendermint/tendermint/crypto/encoding/amino"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/tendermint/tendermint/crypto/xsalsa20symmetric"

cmn "github.com/tendermint/tendermint/libs/common"
Expand Down Expand Up @@ -106,7 +106,7 @@ func EncryptArmorPrivKey(privKey crypto.PrivKey, passphrase string) string {
// encrypted priv key.
func encryptPrivKey(privKey crypto.PrivKey, passphrase string) (saltBytes []byte, encBytes []byte) {
saltBytes = crypto.CRandBytes(16)
key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), BcryptSecurityParameter)
key, err := bcrypt.GenerateFromPassword([]byte(passphrase), BcryptSecurityParameter)
if err != nil {
cmn.Exit("Error generating bcrypt key from passphrase: " + err.Error())
}
Expand Down Expand Up @@ -140,7 +140,7 @@ func UnarmorDecryptPrivKey(armorStr string, passphrase string) (crypto.PrivKey,
}

func decryptPrivKey(saltBytes []byte, encBytes []byte, passphrase string) (privKey crypto.PrivKey, err error) {
key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), BcryptSecurityParameter)
key, err := bcrypt.GenerateFromPassword([]byte(passphrase), BcryptSecurityParameter)
if err != nil {
cmn.Exit("Error generating bcrypt key from passphrase: " + err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion crypto/keys/mintkey/mintkey_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func BenchmarkBcryptGenerateFromPassword(b *testing.B) {
saltBytes := crypto.CRandBytes(16)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := bcrypt.GenerateFromPassword(saltBytes, passphrase, param)
_, err := bcrypt.GenerateFromPassword(passphrase, param)
require.Nil(b, err)
}
})
Expand Down

0 comments on commit 7058917

Please sign in to comment.