Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
1709de0e
Commit
1709de0e
authored
Mar 18, 2019
by
Sietse Ringers
Browse files
Use CSPRNG for session tokens
parent
0371834a
Pipeline
#20094
canceled with stages
in 1 minute and 58 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
internal/servercore/sessions.go
View file @
1709de0e
package
servercore
import
(
"
math
/rand"
"
crypto
/rand"
"sync"
"time"
...
...
@@ -63,10 +63,6 @@ var (
maxProtocolVersion
=
irma
.
NewVersion
(
2
,
4
)
)
func
init
()
{
rand
.
Seed
(
time
.
Now
()
.
UnixNano
())
}
func
(
s
*
memorySessionStore
)
get
(
t
string
)
*
session
{
s
.
RLock
()
defer
s
.
RUnlock
()
...
...
@@ -174,9 +170,17 @@ func (s *Server) newSession(action irma.Action, request irma.RequestorRequest) *
}
func
newSessionToken
()
string
{
b
:=
make
([]
byte
,
20
)
count
:=
20
r
:=
make
([]
byte
,
count
)
_
,
err
:=
rand
.
Read
(
r
)
if
err
!=
nil
{
panic
(
err
)
}
b
:=
make
([]
byte
,
count
)
for
i
:=
range
b
{
b
[
i
]
=
sessionChars
[
r
and
.
Int63
()
%
int64
(
len
(
sessionChars
))]
b
[
i
]
=
sessionChars
[
r
[
i
]
%
byte
(
len
(
sessionChars
))]
}
return
string
(
b
)
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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