tangled
alpha
login
or
join now
futur.blue
/
pegasus
56
fork
atom
objective categorical abstract machine language personal data server
56
fork
atom
overview
issues
2
pulls
pipelines
Actually rotate dpop nonces
futur.blue
2 months ago
1286590e
7742b350
verified
This commit was signed with the committer's
known signature
.
futur.blue
SSH Key Fingerprint:
SHA256:QHGqHWNpqYyw9bt8KmPuJIyeZX9SZewBZ0PR1COtKQ0=
+24
-11
1 changed file
expand all
collapse all
unified
split
pegasus
lib
oauth
dpop.ml
+24
-11
pegasus/lib/oauth/dpop.ml
···
49
49
(Int64.of_float (Unix.gettimeofday () *. 1000.))
50
50
!nonce_state.rotation_interval_ms
51
51
in
52
52
-
if now_counter <> !nonce_state.counter then (
53
53
-
!nonce_state.prev <- !nonce_state.curr ;
54
54
-
!nonce_state.curr <- !nonce_state.next ;
55
55
-
!nonce_state.next <-
56
56
-
compute_nonce !nonce_state.secret (Int64.succ now_counter) ;
57
57
-
!nonce_state.counter <- now_counter ) ;
52
52
+
let diff = Int64.sub now_counter !nonce_state.counter in
53
53
+
( match diff with
54
54
+
| 0L ->
55
55
+
()
56
56
+
| 1L ->
57
57
+
!nonce_state.prev <- !nonce_state.curr ;
58
58
+
!nonce_state.curr <- !nonce_state.next ;
59
59
+
!nonce_state.next <-
60
60
+
compute_nonce !nonce_state.secret (Int64.succ now_counter)
61
61
+
| 2L ->
62
62
+
!nonce_state.prev <- !nonce_state.next ;
63
63
+
!nonce_state.curr <- compute_nonce !nonce_state.secret now_counter ;
64
64
+
!nonce_state.next <-
65
65
+
compute_nonce !nonce_state.secret (Int64.succ now_counter)
66
66
+
| _ ->
67
67
+
!nonce_state.prev <-
68
68
+
compute_nonce !nonce_state.secret (Int64.pred now_counter) ;
69
69
+
!nonce_state.curr <- compute_nonce !nonce_state.secret now_counter ;
70
70
+
!nonce_state.next <-
71
71
+
compute_nonce !nonce_state.secret (Int64.succ now_counter) ) ;
72
72
+
!nonce_state.counter <- now_counter ;
58
73
!nonce_state.next
59
74
60
75
let verify_nonce nonce =
61
61
-
let valid =
62
62
-
nonce = !nonce_state.prev || nonce = !nonce_state.curr
63
63
-
|| nonce = !nonce_state.next
64
64
-
in
65
65
-
ignore next_nonce ; valid
76
76
+
let _ = next_nonce () in
77
77
+
nonce = !nonce_state.prev || nonce = !nonce_state.curr
78
78
+
|| nonce = !nonce_state.next
66
79
67
80
let add_jti jti =
68
81
let expires_at = int_of_float (Unix.gettimeofday ()) + Constants.jti_ttl_s in