diff options
author | obscuren <geffobscura@gmail.com> | 2015-01-23 05:42:39 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-01-23 05:42:39 +0800 |
commit | a125b0fbc319a3d86f61a7e6c4036dc24a211943 (patch) | |
tree | fc75d65294b7445a91aaf66b83864ee439434d87 /crypto/key_store_passphrase.go | |
parent | 0dfe5113709d2981ef2ec8885d831a38cf2e4f91 (diff) | |
parent | 8af42d42da1d428025622d3b76982798ec9436bd (diff) | |
download | go-tangerine-a125b0fbc319a3d86f61a7e6c4036dc24a211943.tar go-tangerine-a125b0fbc319a3d86f61a7e6c4036dc24a211943.tar.gz go-tangerine-a125b0fbc319a3d86f61a7e6c4036dc24a211943.tar.bz2 go-tangerine-a125b0fbc319a3d86f61a7e6c4036dc24a211943.tar.lz go-tangerine-a125b0fbc319a3d86f61a7e6c4036dc24a211943.tar.xz go-tangerine-a125b0fbc319a3d86f61a7e6c4036dc24a211943.tar.zst go-tangerine-a125b0fbc319a3d86f61a7e6c4036dc24a211943.zip |
Merge branch 'import_presale_keys' of https://github.com/Gustav-Simonsson/go-ethereum into Gustav-Simonsson-import_presale_keys
Conflicts:
crypto/crypto.go
Diffstat (limited to 'crypto/key_store_passphrase.go')
-rw-r--r-- | crypto/key_store_passphrase.go | 46 |
1 files changed, 1 insertions, 45 deletions
diff --git a/crypto/key_store_passphrase.go b/crypto/key_store_passphrase.go index e30a0a785..80bf49d68 100644 --- a/crypto/key_store_passphrase.go +++ b/crypto/key_store_passphrase.go @@ -178,22 +178,10 @@ func DecryptKey(ks keyStorePassphrase, keyId *uuid.UUID, auth string) (keyBytes if err != nil { return nil, err } - - AES256Block, err := aes.NewCipher(derivedKey) + plainText, err := aesCBCDecrypt(derivedKey, cipherText, iv) if err != nil { return nil, err } - - AES256CBCDecrypter := cipher.NewCBCDecrypter(AES256Block, iv) - paddedPlainText := make([]byte, len(cipherText)) - AES256CBCDecrypter.CryptBlocks(paddedPlainText, cipherText) - - plainText := PKCS7Unpad(paddedPlainText) - if plainText == nil { - err = errors.New("Decryption failed: PKCS7Unpad failed after decryption") - return nil, err - } - keyBytes = plainText[:len(plainText)-32] keyBytesHash := plainText[len(plainText)-32:] if !bytes.Equal(Sha3(keyBytes), keyBytesHash) { @@ -211,35 +199,3 @@ func getEntropyCSPRNG(n int) []byte { } return mainBuff } - -// From https://leanpub.com/gocrypto/read#leanpub-auto-block-cipher-modes -func PKCS7Pad(in []byte) []byte { - padding := 16 - (len(in) % 16) - if padding == 0 { - padding = 16 - } - for i := 0; i < padding; i++ { - in = append(in, byte(padding)) - } - return in -} - -func PKCS7Unpad(in []byte) []byte { - if len(in) == 0 { - return nil - } - - padding := in[len(in)-1] - if int(padding) > len(in) || padding > aes.BlockSize { - return nil - } else if padding == 0 { - return nil - } - - for i := len(in) - 1; i > len(in)-int(padding)-1; i-- { - if in[i] != padding { - return nil - } - } - return in[:len(in)-int(padding)] -} |