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
35b80f18
Commit
35b80f18
authored
Mar 23, 2019
by
Guillaume Ballet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix linter issues
parent
bcf3c52a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
17 deletions
+13
-17
securechannel.go
accounts/scwallet/securechannel.go
+4
-4
wallet.go
accounts/scwallet/wallet.go
+9
-13
No files found.
accounts/scwallet/securechannel.go
View file @
35b80f18
...
...
@@ -135,7 +135,7 @@ func (s *SecureChannelSession) Unpair() error {
return
fmt
.
Errorf
(
"Cannot unpair: not paired"
)
}
_
,
err
:=
s
.
T
ransmitEncrypted
(
claSCWallet
,
insUnpair
,
s
.
PairingIndex
,
0
,
[]
byte
{})
_
,
err
:=
s
.
t
ransmitEncrypted
(
claSCWallet
,
insUnpair
,
s
.
PairingIndex
,
0
,
[]
byte
{})
if
err
!=
nil
{
return
err
}
...
...
@@ -180,7 +180,7 @@ func (s *SecureChannelSession) mutuallyAuthenticate() error {
return
err
}
response
,
err
:=
s
.
T
ransmitEncrypted
(
claSCWallet
,
insMutuallyAuthenticate
,
0
,
0
,
data
)
response
,
err
:=
s
.
t
ransmitEncrypted
(
claSCWallet
,
insMutuallyAuthenticate
,
0
,
0
,
data
)
if
err
!=
nil
{
return
err
}
...
...
@@ -219,8 +219,8 @@ func (s *SecureChannelSession) pair(p1 uint8, data []byte) (*responseAPDU, error
})
}
//
T
ransmitEncrypted sends an encrypted message, and decrypts and returns the response.
func
(
s
*
SecureChannelSession
)
T
ransmitEncrypted
(
cla
,
ins
,
p1
,
p2
byte
,
data
[]
byte
)
(
*
responseAPDU
,
error
)
{
//
t
ransmitEncrypted sends an encrypted message, and decrypts and returns the response.
func
(
s
*
SecureChannelSession
)
t
ransmitEncrypted
(
cla
,
ins
,
p1
,
p2
byte
,
data
[]
byte
)
(
*
responseAPDU
,
error
)
{
if
s
.
iv
==
nil
{
return
nil
,
fmt
.
Errorf
(
"Channel not open"
)
}
...
...
accounts/scwallet/wallet.go
View file @
35b80f18
...
...
@@ -97,10 +97,6 @@ const (
P1DeriveKeyFromMaster
=
uint8
(
0x00
)
P1DeriveKeyFromParent
=
uint8
(
0x01
)
P1DeriveKeyFromCurrent
=
uint8
(
0x10
)
deriveP1Assisted
=
uint8
(
0x01
)
deriveP1Append
=
uint8
(
0x80
)
deriveP2KeyPath
=
uint8
(
0x00
)
deriveP2PublicKey
=
uint8
(
0x01
)
statusP1WalletStatus
=
uint8
(
0x00
)
statusP1Path
=
uint8
(
0x01
)
signP1PrecomputedHash
=
uint8
(
0x01
)
...
...
@@ -803,7 +799,7 @@ func (s *Session) unpair() error {
// verifyPin unlocks a wallet with the provided pin.
func
(
s
*
Session
)
verifyPin
(
pin
[]
byte
)
error
{
if
_
,
err
:=
s
.
Channel
.
T
ransmitEncrypted
(
claSCWallet
,
insVerifyPin
,
0
,
0
,
pin
);
err
!=
nil
{
if
_
,
err
:=
s
.
Channel
.
t
ransmitEncrypted
(
claSCWallet
,
insVerifyPin
,
0
,
0
,
pin
);
err
!=
nil
{
return
err
}
s
.
verified
=
true
...
...
@@ -813,7 +809,7 @@ func (s *Session) verifyPin(pin []byte) error {
// unblockPin unblocks a wallet with the provided puk and resets the pin to the
// new one specified.
func
(
s
*
Session
)
unblockPin
(
pukpin
[]
byte
)
error
{
if
_
,
err
:=
s
.
Channel
.
T
ransmitEncrypted
(
claSCWallet
,
insUnblockPin
,
0
,
0
,
pukpin
);
err
!=
nil
{
if
_
,
err
:=
s
.
Channel
.
t
ransmitEncrypted
(
claSCWallet
,
insUnblockPin
,
0
,
0
,
pukpin
);
err
!=
nil
{
return
err
}
s
.
verified
=
true
...
...
@@ -849,7 +845,7 @@ type walletStatus struct {
// walletStatus fetches the wallet's status from the card.
func
(
s
*
Session
)
walletStatus
()
(
*
walletStatus
,
error
)
{
response
,
err
:=
s
.
Channel
.
T
ransmitEncrypted
(
claSCWallet
,
insStatus
,
statusP1WalletStatus
,
0
,
nil
)
response
,
err
:=
s
.
Channel
.
t
ransmitEncrypted
(
claSCWallet
,
insStatus
,
statusP1WalletStatus
,
0
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -882,7 +878,7 @@ func (s *Session) walletStatus() (*walletStatus, error) {
// derivationPath fetches the wallet's current derivation path from the card.
func
(
s
*
Session
)
derivationPath
()
(
accounts
.
DerivationPath
,
error
)
{
response
,
err
:=
s
.
Channel
.
T
ransmitEncrypted
(
claSCWallet
,
insStatus
,
statusP1Path
,
0
,
nil
)
response
,
err
:=
s
.
Channel
.
t
ransmitEncrypted
(
claSCWallet
,
insStatus
,
statusP1Path
,
0
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -922,7 +918,7 @@ func (s *Session) initialize(seed []byte) error {
// Nasty hack to force the top-level struct tag to be context-specific
data
[
0
]
=
0xA1
_
,
err
=
s
.
Channel
.
T
ransmitEncrypted
(
claSCWallet
,
insLoadKey
,
0x02
,
0
,
data
)
_
,
err
=
s
.
Channel
.
t
ransmitEncrypted
(
claSCWallet
,
insLoadKey
,
0x02
,
0
,
data
)
return
err
}
...
...
@@ -952,12 +948,12 @@ func (s *Session) derive(path accounts.DerivationPath) (accounts.Account, error)
}
}
_
,
err
=
s
.
Channel
.
T
ransmitEncrypted
(
claSCWallet
,
insDeriveKey
,
p1
,
0
,
data
.
Bytes
())
_
,
err
=
s
.
Channel
.
t
ransmitEncrypted
(
claSCWallet
,
insDeriveKey
,
p1
,
0
,
data
.
Bytes
())
if
err
!=
nil
{
return
accounts
.
Account
{},
err
}
response
,
err
:=
s
.
Channel
.
T
ransmitEncrypted
(
claSCWallet
,
insSign
,
0
,
0
,
DerivationSignatureHash
[
:
])
response
,
err
:=
s
.
Channel
.
t
ransmitEncrypted
(
claSCWallet
,
insSign
,
0
,
0
,
DerivationSignatureHash
[
:
])
if
err
!=
nil
{
return
accounts
.
Account
{},
err
}
...
...
@@ -991,7 +987,7 @@ type keyExport struct {
// publicKey returns the public key for the current derivation path.
func
(
s
*
Session
)
publicKey
()
([]
byte
,
error
)
{
response
,
err
:=
s
.
Channel
.
T
ransmitEncrypted
(
claSCWallet
,
insExportKey
,
exportP1Any
,
exportP2Pubkey
,
nil
)
response
,
err
:=
s
.
Channel
.
t
ransmitEncrypted
(
claSCWallet
,
insExportKey
,
exportP1Any
,
exportP2Pubkey
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -1022,7 +1018,7 @@ func (s *Session) sign(path accounts.DerivationPath, hash []byte) ([]byte, error
}
deriveTime
:=
time
.
Now
()
response
,
err
:=
s
.
Channel
.
T
ransmitEncrypted
(
claSCWallet
,
insSign
,
signP1PrecomputedHash
,
signP2OnlyBlock
,
hash
)
response
,
err
:=
s
.
Channel
.
t
ransmitEncrypted
(
claSCWallet
,
insSign
,
signP1PrecomputedHash
,
signP2OnlyBlock
,
hash
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
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