Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
irmago
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
IRMA
Github mirrors
irmago
Commits
4b186703
Commit
4b186703
authored
Jan 12, 2020
by
Sietse Ringers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: UpdateLatest revocation update mechanism
parent
05c915e1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
8 deletions
+14
-8
internal/servercore/api.go
internal/servercore/api.go
+1
-1
irmaclient/revocation.go
irmaclient/revocation.go
+1
-1
revocation.go
revocation.go
+11
-5
revocation_db.go
revocation_db.go
+1
-1
No files found.
internal/servercore/api.go
View file @
4b186703
...
...
@@ -372,7 +372,7 @@ func (s *Server) handleRevocationMessage(
noun
,
method
string
,
args
[]
string
,
headers
map
[
string
][]
string
,
message
[]
byte
,
)
(
int
,
[]
byte
)
{
if
(
noun
==
"updatefrom"
)
&&
method
==
http
.
MethodGet
{
if
len
(
args
)
!=
2
{
if
len
(
args
)
!=
3
{
return
server
.
BinaryResponse
(
nil
,
server
.
RemoteError
(
server
.
ErrorInvalidRequest
,
"GET updatefrom expects 3 url arguments"
))
}
i
,
err
:=
strconv
.
ParseUint
(
args
[
1
],
10
,
64
)
...
...
irmaclient/revocation.go
View file @
4b186703
...
...
@@ -125,7 +125,7 @@ func (client *Client) nonrevUpdate(typ irma.CredentialTypeIdentifier, updates ma
u
:=
map
[
uint
]
*
revocation
.
Update
{}
for
counter
,
l
:=
range
lowest
{
update
:=
updates
[
counter
]
if
update
!=
nil
&&
len
(
update
.
Events
)
>
0
&&
update
.
Events
[
0
]
.
Index
<=
l
{
if
update
!=
nil
&&
len
(
update
.
Events
)
>
0
&&
update
.
Events
[
0
]
.
Index
<=
l
+
1
{
u
[
counter
]
=
update
}
else
{
var
err
error
...
...
revocation.go
View file @
4b186703
...
...
@@ -3,6 +3,7 @@ package irma
import
(
"database/sql/driver"
"fmt"
"sort"
"time"
"github.com/fxamacker/cbor"
...
...
@@ -123,9 +124,9 @@ const (
// In addition this mode exposes the same endpoints as RevocationModeProxy.
RevocationModeServer
RevocationMode
=
"server"
//
revocationUpdate
Count specifies how many revocation events are attached to session requests
//
RevocationDefaultEvent
Count specifies how many revocation events are attached to session requests
// for the client to update its revocation state.
revocationUpdate
Count
=
5
RevocationDefaultEvent
Count
=
5
// revocationMaxAccumulatorAge is the default maximum in seconds for the 'accumulator age',
// which we define to be the amount of time since the last confirmation from the RA that the
...
...
@@ -181,7 +182,7 @@ func (rs *RevocationStorage) UpdateFrom(typ CredentialTypeIdentifier, pkcounter
return
err
}
var
events
[]
*
EventRecord
if
err
:=
tx
.
From
(
&
events
,
"cred_type = ? and pk_counter = ? and index >= ?"
,
typ
,
pkcounter
,
index
);
err
!=
nil
{
if
err
:=
tx
.
From
(
&
events
,
"cred_type = ? and pk_counter = ? and
event
index >= ?"
,
typ
,
pkcounter
,
index
);
err
!=
nil
{
return
err
}
update
=
rs
.
newUpdate
(
acc
,
events
)
...
...
@@ -236,6 +237,11 @@ func (*RevocationStorage) newUpdates(records []*AccumulatorRecord, events []*Eve
}
update
.
Events
=
append
(
update
.
Events
,
e
.
Event
())
}
for
_
,
update
:=
range
updates
{
sort
.
Slice
(
update
.
Events
,
func
(
i
,
j
int
)
bool
{
return
update
.
Events
[
i
]
.
Index
<
update
.
Events
[
j
]
.
Index
})
}
return
updates
}
...
...
@@ -397,7 +403,7 @@ func (rs *RevocationStorage) accumulator(tx revStorage, typ CredentialTypeIdenti
// Methods to update from remote revocation server
func
(
rs
*
RevocationStorage
)
UpdateDB
(
typ
CredentialTypeIdentifier
)
error
{
updates
,
err
:=
rs
.
client
.
FetchUpdateLatest
(
typ
,
revocationUpdate
Count
)
updates
,
err
:=
rs
.
client
.
FetchUpdateLatest
(
typ
,
RevocationDefaultEvent
Count
)
if
err
!=
nil
{
return
err
}
...
...
@@ -537,7 +543,7 @@ func (rs *RevocationStorage) SetRevocationUpdates(b *BaseRequest) error {
return
err
}
}
b
.
RevocationUpdates
[
credid
],
err
=
rs
.
UpdateLatest
(
credid
,
revocationUpdate
Count
)
b
.
RevocationUpdates
[
credid
],
err
=
rs
.
UpdateLatest
(
credid
,
RevocationDefaultEvent
Count
)
if
err
!=
nil
{
return
err
}
...
...
revocation_db.go
View file @
4b186703
...
...
@@ -136,7 +136,7 @@ func (s sqlRevStorage) Latest(dest interface{}, count uint64, query interface{},
return
s
.
gorm
.
Where
(
query
,
args
...
)
.
Limit
(
count
)
.
Set
(
"gorm:order_by_primary_key"
,
"
A
SC"
)
.
Set
(
"gorm:order_by_primary_key"
,
"
DE
SC"
)
.
Find
(
dest
)
.
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