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
313eec33
Commit
313eec33
authored
Apr 21, 2015
by
Gustav Simonsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Add key header to unencrypted key file"
This reverts commit a94d4ba0b53c4558ab838aaed635a2ff66ddfa53.
parent
8754f2b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
16 deletions
+8
-16
key.go
crypto/key.go
+5
-12
key_store_passphrase.go
crypto/key_store_passphrase.go
+3
-4
No files found.
crypto/key.go
View file @
313eec33
...
...
@@ -45,28 +45,27 @@ type Key struct {
type
plainKeyJSON
struct
{
Id
[]
byte
Address
[]
byte
KeyHeader
keyHeaderJSON
PrivateKey
[]
byte
}
type
encryptedKeyJSON
struct
{
Id
[]
byte
Address
[]
byte
KeyHeader
keyHeaderJSON
Crypto
cipherJSON
Id
[]
byte
Address
[]
byte
Crypto
cipherJSON
}
type
cipherJSON
struct
{
MAC
[]
byte
Salt
[]
byte
IV
[]
byte
KeyHeader
keyHeaderJSON
CipherText
[]
byte
}
type
keyHeaderJSON
struct
{
Version
string
Kdf
string
KdfParams
*
scryptParamsJSON
// TODO: make more generic?
KdfParams
scryptParamsJSON
// TODO: make more generic?
}
type
scryptParamsJSON
struct
{
...
...
@@ -78,15 +77,9 @@ type scryptParamsJSON struct {
}
func
(
k
*
Key
)
MarshalJSON
()
(
j
[]
byte
,
err
error
)
{
keyHeader
:=
keyHeaderJSON
{
Version
:
"1"
,
Kdf
:
""
,
KdfParams
:
nil
,
}
jStruct
:=
plainKeyJSON
{
k
.
Id
,
k
.
Address
.
Bytes
(),
keyHeader
,
FromECDSA
(
k
.
PrivateKey
),
}
j
,
err
=
json
.
Marshal
(
jStruct
)
...
...
crypto/key_store_passphrase.go
View file @
313eec33
...
...
@@ -153,7 +153,7 @@ func (ks keyStorePassphrase) StoreKey(key *Key, auth string) (err error) {
keyHeaderJSON
:=
keyHeaderJSON
{
Version
:
keyHeaderVersion
,
Kdf
:
keyHeaderKDF
,
KdfParams
:
&
paramsJSON
,
KdfParams
:
paramsJSON
,
}
keyHeaderJSONStr
,
err
:=
json
.
Marshal
(
keyHeaderJSON
)
...
...
@@ -167,12 +167,12 @@ func (ks keyStorePassphrase) StoreKey(key *Key, auth string) (err error) {
mac
,
salt
,
iv
,
keyHeaderJSON
,
cipherText
,
}
keyStruct
:=
encryptedKeyJSON
{
key
.
Id
,
key
.
Address
.
Bytes
(),
keyHeaderJSON
,
cipherStruct
,
}
keyJSON
,
err
:=
json
.
Marshal
(
keyStruct
)
...
...
@@ -204,11 +204,10 @@ func DecryptKey(ks keyStorePassphrase, keyAddr common.Address, auth string) (key
err
=
json
.
Unmarshal
(
fileContent
,
keyProtected
)
keyId
=
keyProtected
.
Id
keyHeader
:=
keyProtected
.
KeyHeader
mac
:=
keyProtected
.
Crypto
.
MAC
salt
:=
keyProtected
.
Crypto
.
Salt
iv
:=
keyProtected
.
Crypto
.
IV
keyHeader
:=
keyProtected
.
Crypto
.
KeyHeader
cipherText
:=
keyProtected
.
Crypto
.
CipherText
// used in MAC
...
...
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