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
7cc6b801
Commit
7cc6b801
authored
Sep 23, 2016
by
Gustav Simonsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts: left pad keybytes-to-encrypt, add 30/31 byte keys tests
parent
863d166c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
1 deletion
+62
-1
key_store_passphrase.go
accounts/key_store_passphrase.go
+2
-1
key_store_test.go
accounts/key_store_test.go
+12
-0
v3_test_vector.json
accounts/testdata/v3_test_vector.json
+48
-0
No files found.
accounts/key_store_passphrase.go
View file @
7cc6b801
...
@@ -107,7 +107,8 @@ func EncryptKey(key *Key, auth string, scryptN, scryptP int) ([]byte, error) {
...
@@ -107,7 +107,8 @@ func EncryptKey(key *Key, auth string, scryptN, scryptP int) ([]byte, error) {
return
nil
,
err
return
nil
,
err
}
}
encryptKey
:=
derivedKey
[
:
16
]
encryptKey
:=
derivedKey
[
:
16
]
keyBytes
:=
crypto
.
FromECDSA
(
key
.
PrivateKey
)
keyBytes0
:=
crypto
.
FromECDSA
(
key
.
PrivateKey
)
keyBytes
:=
common
.
LeftPadBytes
(
keyBytes0
,
32
)
iv
:=
randentropy
.
GetEntropyCSPRNG
(
aes
.
BlockSize
)
// 16
iv
:=
randentropy
.
GetEntropyCSPRNG
(
aes
.
BlockSize
)
// 16
cipherText
,
err
:=
aesCTRXOR
(
encryptKey
,
keyBytes
,
iv
)
cipherText
,
err
:=
aesCTRXOR
(
encryptKey
,
keyBytes
,
iv
)
...
...
accounts/key_store_test.go
View file @
7cc6b801
...
@@ -239,3 +239,15 @@ func TestKeyForDirectICAP(t *testing.T) {
...
@@ -239,3 +239,15 @@ func TestKeyForDirectICAP(t *testing.T) {
t
.
Errorf
(
"Expected first address byte to be zero, have: %s"
,
key
.
Address
.
Hex
())
t
.
Errorf
(
"Expected first address byte to be zero, have: %s"
,
key
.
Address
.
Hex
())
}
}
}
}
func
TestV3_31_Byte_Key
(
t
*
testing
.
T
)
{
t
.
Parallel
()
tests
:=
loadKeyStoreTestV3
(
"testdata/v3_test_vector.json"
,
t
)
testDecryptV3
(
tests
[
"31_byte_key"
],
t
)
}
func
TestV3_30_Byte_Key
(
t
*
testing
.
T
)
{
t
.
Parallel
()
tests
:=
loadKeyStoreTestV3
(
"testdata/v3_test_vector.json"
,
t
)
testDecryptV3
(
tests
[
"30_byte_key"
],
t
)
}
accounts/testdata/v3_test_vector.json
View file @
7cc6b801
...
@@ -45,5 +45,53 @@
...
@@ -45,5 +45,53 @@
},
},
"password"
:
"testpassword"
,
"password"
:
"testpassword"
,
"priv"
:
"7a28b5ba57c53603b0b07b56bba752f7784bf506fa95edc395f5cf6c7514fe9d"
"priv"
:
"7a28b5ba57c53603b0b07b56bba752f7784bf506fa95edc395f5cf6c7514fe9d"
},
"31_byte_key"
:
{
"json"
:
{
"crypto"
:
{
"cipher"
:
"aes-128-ctr"
,
"cipherparams"
:
{
"iv"
:
"e0c41130a323adc1446fc82f724bca2f"
},
"ciphertext"
:
"9517cd5bdbe69076f9bf5057248c6c050141e970efa36ce53692d5d59a3984"
,
"kdf"
:
"scrypt"
,
"kdfparams"
:
{
"dklen"
:
32
,
"n"
:
2
,
"r"
:
8
,
"p"
:
1
,
"salt"
:
"711f816911c92d649fb4c84b047915679933555030b3552c1212609b38208c63"
},
"mac"
:
"d5e116151c6aa71470e67a7d42c9620c75c4d23229847dcc127794f0732b0db5"
},
"id"
:
"fecfc4ce-e956-48fd-953b-30f8b52ed66c"
,
"version"
:
3
},
"password"
:
"foo"
,
"priv"
:
"fa7b3db73dc7dfdf8c5fbdb796d741e4488628c41fc4febd9160a866ba0f35"
},
"30_byte_key"
:
{
"json"
:
{
"crypto"
:
{
"cipher"
:
"aes-128-ctr"
,
"cipherparams"
:
{
"iv"
:
"3ca92af36ad7c2cd92454c59cea5ef00"
},
"ciphertext"
:
"108b7d34f3442fc26ab1ab90ca91476ba6bfa8c00975a49ef9051dc675aa"
,
"kdf"
:
"scrypt"
,
"kdfparams"
:
{
"dklen"
:
32
,
"n"
:
2
,
"r"
:
8
,
"p"
:
1
,
"salt"
:
"d0769e608fb86cda848065642a9c6fa046845c928175662b8e356c77f914cd3b"
},
"mac"
:
"75d0e6759f7b3cefa319c3be41680ab6beea7d8328653474bd06706d4cc67420"
},
"id"
:
"a37e1559-5955-450d-8075-7b8931b392b2"
,
"version"
:
3
},
"password"
:
"foo"
,
"priv"
:
"81c29e8142bb6a81bef5a92bda7a8328a5c85bb2f9542e76f9b0f94fc018"
}
}
}
}
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