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
fc3000d6
Commit
fc3000d6
authored
Apr 04, 2019
by
Guillaume Ballet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more review feedback
parent
d2daff42
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
11 deletions
+10
-11
hub.go
accounts/scwallet/hub.go
+6
-7
securechannel.go
accounts/scwallet/securechannel.go
+4
-4
No files found.
accounts/scwallet/hub.go
View file @
fc3000d6
...
...
@@ -36,6 +36,7 @@ import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"sort"
"sync"
"time"
...
...
@@ -111,10 +112,11 @@ func (hub *Hub) readPairings() error {
}
func
(
hub
*
Hub
)
writePairings
()
error
{
pairingFile
,
err
:=
os
.
OpenFile
(
filepath
.
Join
(
hub
.
datadir
,
"smartcards.json"
),
os
.
O_RDWR
|
os
.
O_CREATE
,
0755
)
pairingFile
,
err
:=
os
.
OpenFile
(
filepath
.
Join
(
hub
.
datadir
,
"smartcards.json"
),
os
.
O_RDWR
|
os
.
O_CREATE
,
0755
)
if
err
!=
nil
{
return
err
}
defer
pairingFile
.
Close
()
pairings
:=
make
([]
smartcardPairing
,
0
,
len
(
hub
.
pairings
))
for
_
,
pairing
:=
range
hub
.
pairings
{
...
...
@@ -130,15 +132,11 @@ func (hub *Hub) writePairings() error {
return
err
}
return
pairingFile
.
Close
()
return
nil
}
func
(
hub
*
Hub
)
pairing
(
wallet
*
Wallet
)
*
smartcardPairing
{
if
pairing
,
ok
:=
hub
.
pairings
[
string
(
wallet
.
PublicKey
)];
ok
{
return
&
pairing
}
return
nil
if
ok
{
if
pairing
,
ok
:=
hub
.
pairings
[
string
(
wallet
.
PublicKey
)];
ok
{
return
&
pairing
}
return
nil
...
...
@@ -209,6 +207,7 @@ func (hub *Hub) refreshWallets() {
// want to fill the user's log with errors, so filter those out.
if
err
.
Error
()
!=
"scard: Cannot find a smart card reader."
{
log
.
Error
(
"Failed to enumerate smart card readers"
,
"err"
,
err
)
return
}
}
// Transform the current list of wallets into the new one
...
...
accounts/scwallet/securechannel.go
View file @
fc3000d6
...
...
@@ -229,8 +229,8 @@ func (s *SecureChannelSession) transmitEncrypted(cla, ins, p1, p2 byte, data []b
if
err
!=
nil
{
return
nil
,
err
}
meta
:=
[
]
byte
{
cla
,
ins
,
p1
,
p2
,
byte
(
len
(
data
)
+
scBlockSize
),
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}
if
err
=
s
.
updateIV
(
meta
,
data
);
err
!=
nil
{
meta
:=
[
16
]
byte
{
cla
,
ins
,
p1
,
p2
,
byte
(
len
(
data
)
+
scBlockSize
)
}
if
err
=
s
.
updateIV
(
meta
[
:
]
,
data
);
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -249,7 +249,7 @@ func (s *SecureChannelSession) transmitEncrypted(cla, ins, p1, p2 byte, data []b
return
nil
,
err
}
rmeta
:=
[
]
byte
{
byte
(
len
(
response
.
Data
)),
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}
rmeta
:=
[
16
]
byte
{
byte
(
len
(
response
.
Data
))
}
rmac
:=
response
.
Data
[
:
len
(
s
.
iv
)]
rdata
:=
response
.
Data
[
len
(
s
.
iv
)
:
]
plainData
,
err
:=
s
.
decryptAPDU
(
rdata
)
...
...
@@ -257,7 +257,7 @@ func (s *SecureChannelSession) transmitEncrypted(cla, ins, p1, p2 byte, data []b
return
nil
,
err
}
if
err
=
s
.
updateIV
(
rmeta
,
rdata
);
err
!=
nil
{
if
err
=
s
.
updateIV
(
rmeta
[
:
]
,
rdata
);
err
!=
nil
{
return
nil
,
err
}
if
!
bytes
.
Equal
(
s
.
iv
,
rmac
)
{
...
...
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