Repository navigation
device: report whether a peer's session used a hybrid handshake - #145
Conversation
48bfd68 to
b4912f1
Compare
| // SessionInfo returns information about the peer's current session | ||
| // and true if the session is usable, otherwise nil and false. | ||
| func (p *Peer) SessionInfo() (_ *PeerSessionInfo, ok bool) { |
There was a problem hiding this comment.
On second thought, returning the session state as a struct instead of a bool makes more sense and helps us distinguish between "no usable session" and "a classic/non-hybrid-pq session" or extend the session info in the future, so I changed it in b4912f1.
b4912f1 to
6a8d19c
Compare
| // SessionInfo returns information about the peer's current session | ||
| // and true if the session is usable, otherwise nil and false. | ||
| func (p *Peer) SessionInfo() (_ *PeerSessionInfo, ok bool) { | ||
| p.keypairs.RLock() |
There was a problem hiding this comment.
I believe you can derive this more cheaply from:
p.sessionState.Lock()
established := p.sessionState.current == PeerSessionEstablished
p.sessionState.Unlock()
Please also keep the lock bounds shorter than a potential allocation. While preferrably the peersessioninfo struct doesn't escape in any current implementation, it may well in the future and so I would recommend avoiding holding the lock across an allocation boundary.
raggi
left a comment
There was a problem hiding this comment.
The main change I would really like to see is the removal of the allocation inside the lock bound.
The design to push this through the existing peer state API is preferred but not manadatory, it's just weird to end up with two things so similarly named, covering so much the same kind of thing but happenign to be slightly different and dependent on each other.
| // Hybrid is whether the session keys were derived | ||
| // from a hybrid post-quantum handshake, | ||
| // which gives the session hybrid forward secrecy. | ||
| Hybrid bool |
There was a problem hiding this comment.
I'm assuming we don't really care about backwards compatibility here, so if we e.g. change to a different form of hybrid handshake in the future, we're fine changing this to e.g. HybridV1 or something?
2632bdd to
0a64bd9
Compare
Updates tailscale/tailscale#22853 Updates tailscale/corp#50068 Updates tailscale/corp#52622 Signed-off-by: Nick Khyl <nickk@tailscale.com>
0a64bd9 to
3c67285
Compare
|
Reworked to return session info in the PeerSessionStateFunc callback. PTAL? |
raggi
left a comment
There was a problem hiding this comment.
It's pre-existing, but it feels weird that note is both a broadcaster and a recorder, and that's getting more vehement with the way that the bool passes through and that there's one write outside of note already (to sessionExpires).
Perhaps a future refactor should move the sessionState update to it's own call chain.
Updates tailscale/tailscale#22853
Updates tailscale/corp#50068
Updates tailscale/corp#52622
Required by tailscale/tailscale#22868