Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
6f1ca0bc
Commit
6f1ca0bc
authored
Apr 01, 2016
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts: add ErrDecrypt
parent
a9f26dcd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
8 additions
and
9 deletions
+8
-9
account_manager.go
accounts/account_manager.go
+1
-0
key_store_passphrase.go
accounts/key_store_passphrase.go
+2
-3
key_store_test.go
accounts/key_store_test.go
+2
-2
presale.go
accounts/presale.go
+1
-2
accountcmd.go
cmd/geth/accountcmd.go
+1
-1
accountcmd_test.go
cmd/geth/accountcmd_test.go
+1
-1
No files found.
accounts/account_manager.go
View file @
6f1ca0bc
...
...
@@ -38,6 +38,7 @@ import (
var
(
ErrLocked
=
errors
.
New
(
"account is locked"
)
ErrNoMatch
=
errors
.
New
(
"no key for given address or file"
)
ErrDecrypt
=
errors
.
New
(
"could not decrypt key with given passphrase"
)
)
type
Account
struct
{
...
...
accounts/key_store_passphrase.go
View file @
6f1ca0bc
...
...
@@ -31,7 +31,6 @@ import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"path/filepath"
...
...
@@ -214,7 +213,7 @@ func decryptKeyV3(keyProtected *encryptedKeyJSONV3, auth string) (keyBytes []byt
calculatedMAC
:=
crypto
.
Keccak256
(
derivedKey
[
16
:
32
],
cipherText
)
if
!
bytes
.
Equal
(
calculatedMAC
,
mac
)
{
return
nil
,
nil
,
errors
.
New
(
"Decryption failed: MAC mismatch"
)
return
nil
,
nil
,
ErrDecrypt
}
plainText
,
err
:=
aesCTRXOR
(
derivedKey
[
:
16
],
cipherText
,
iv
)
...
...
@@ -248,7 +247,7 @@ func decryptKeyV1(keyProtected *encryptedKeyJSONV1, auth string) (keyBytes []byt
calculatedMAC
:=
crypto
.
Keccak256
(
derivedKey
[
16
:
32
],
cipherText
)
if
!
bytes
.
Equal
(
calculatedMAC
,
mac
)
{
return
nil
,
nil
,
errors
.
New
(
"Decryption failed: MAC mismatch"
)
return
nil
,
nil
,
ErrDecrypt
}
plainText
,
err
:=
aesCBCDecrypt
(
crypto
.
Keccak256
(
derivedKey
[
:
16
])[
:
16
],
cipherText
,
iv
)
...
...
accounts/key_store_test.go
View file @
6f1ca0bc
...
...
@@ -94,8 +94,8 @@ func TestKeyStorePassphraseDecryptionFail(t *testing.T) {
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
_
,
err
=
ks
.
GetKey
(
k1
.
Address
,
account
.
File
,
"bar"
);
err
==
nil
{
t
.
Fatal
(
"no error for invalid passphrase"
)
if
_
,
err
=
ks
.
GetKey
(
k1
.
Address
,
account
.
File
,
"bar"
);
err
!=
ErrDecrypt
{
t
.
Fatal
f
(
"wrong error for invalid passphrase
\n
got %q
\n
want %q"
,
err
,
ErrDecrypt
)
}
}
...
...
accounts/presale.go
View file @
6f1ca0bc
...
...
@@ -22,7 +22,6 @@ import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/crypto"
...
...
@@ -106,7 +105,7 @@ func aesCBCDecrypt(key, cipherText, iv []byte) ([]byte, error) {
decrypter
.
CryptBlocks
(
paddedPlaintext
,
cipherText
)
plaintext
:=
pkcs7Unpad
(
paddedPlaintext
)
if
plaintext
==
nil
{
err
=
errors
.
New
(
"Decryption failed: PKCS7Unpad failed after AES decryption"
)
return
nil
,
ErrDecrypt
}
return
plaintext
,
err
}
...
...
cmd/geth/accountcmd.go
View file @
6f1ca0bc
...
...
@@ -263,7 +263,7 @@ func importWallet(ctx *cli.Context) {
acct
,
err
:=
accman
.
ImportPreSaleKey
(
keyJson
,
passphrase
)
if
err
!=
nil
{
utils
.
Fatalf
(
"
Could not create the account:
%v"
,
err
)
utils
.
Fatalf
(
"%v"
,
err
)
}
fmt
.
Printf
(
"Address: {%x}
\n
"
,
acct
.
Address
)
}
...
...
cmd/geth/accountcmd_test.go
View file @
6f1ca0bc
...
...
@@ -127,7 +127,7 @@ func TestWalletImportBadPassword(t *testing.T) {
geth
.
expect
(
`
!! Unsupported terminal, password will be echoed.
Passphrase: {{.InputLine "wrong"}}
Fatal:
Could not create the account: Decryption failed: PKCS7Unpad failed after AES decryption
Fatal:
could not decrypt key with given passphrase
`
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment