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
0969b35e
Commit
0969b35e
authored
Feb 16, 2016
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypto: code polish + ensure key file contents match with name
parent
cda91ee1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
key_store_passphrase.go
crypto/key_store_passphrase.go
+12
-5
No files found.
crypto/key_store_passphrase.go
View file @
0969b35e
...
...
@@ -34,7 +34,6 @@ import (
"errors"
"fmt"
"io"
"reflect"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto/randentropy"
...
...
@@ -157,8 +156,7 @@ func DecryptKey(keyjson []byte, auth string) (*Key, error) {
keyBytes
,
keyId
[]
byte
err
error
)
v
:=
reflect
.
ValueOf
(
m
[
"version"
])
if
v
.
Kind
()
==
reflect
.
String
&&
v
.
String
()
==
"1"
{
if
version
,
ok
:=
m
[
"version"
]
.
(
string
);
ok
&&
version
==
"1"
{
k
:=
new
(
encryptedKeyJSONV1
)
if
err
:=
json
.
Unmarshal
(
keyjson
,
k
);
err
!=
nil
{
return
nil
,
err
...
...
@@ -183,12 +181,21 @@ func DecryptKey(keyjson []byte, auth string) (*Key, error) {
},
nil
}
func
decryptKeyFromFile
(
keysDirPath
string
,
keyAddr
common
.
Address
,
auth
string
)
(
key
*
Key
,
err
error
)
{
func
decryptKeyFromFile
(
keysDirPath
string
,
keyAddr
common
.
Address
,
auth
string
)
(
*
Key
,
error
)
{
// Load the key from the keystore and decrypt its contents
keyjson
,
err
:=
getKeyFile
(
keysDirPath
,
keyAddr
)
if
err
!=
nil
{
return
nil
,
err
}
return
DecryptKey
(
keyjson
,
auth
)
key
,
err
:=
DecryptKey
(
keyjson
,
auth
)
if
err
!=
nil
{
return
nil
,
err
}
// Make sure we're really operating on the requested key (no swap attacks)
if
keyAddr
!=
key
.
Address
{
return
nil
,
fmt
.
Errorf
(
"key content mismatch: have account %x, want %x"
,
key
.
Address
,
keyAddr
)
}
return
key
,
nil
}
func
decryptKeyV3
(
keyProtected
*
encryptedKeyJSONV3
,
auth
string
)
(
keyBytes
[]
byte
,
keyId
[]
byte
,
err
error
)
{
...
...
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