-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds ake.Server Serde methods #8
Conversation
Thank you ! Nice addition, indeed. I also like the formatting in the test function, it's much better. I left some comments and suggestions. Do you think you can address them or would you prefer me to do it? Also, I pushed some changes that might break some things, I fear that a rebase from the main branch is necessary. |
😄
I'd be happy to address them.
No problem. I'll rebase. |
1517e29
to
86a6fa4
Compare
rebased and pushed. I'll incorporate the suggested changes and push again. |
I just pushed some changes that should simplify the configuration and its usage a bit, but I don't think it impacts your changes |
`internal/ake/server.go`: - remove import of `github.com/bytemare/cryptotools/utils`. - `ake.Server.SerializeState` no longer takes a size parameter. - drop `ake.Server.DeserializeState(data []byte, size int)` in favor of `ake.Server.SetState(clientMac, sessionSecret []byte) error`. - add `ake.Server.ExpectedMAC` accessor. `server.go`: - add `Server.SerializeState() []byte` which delegates to `ake.Server.SerializeState()` - add `Server.DeserializeAKEState(state []byte) error` to set AKE server state using `ake.Server.SetState` - add `Server.ExpectedMAC` which delegates to the `ake.Server.ExpectedMAC` accessor. - update comments to more accurately reflect when AKE server state is set. `tests/opaque_test.go`: - update `FullTest` to use `server.SerializeState()` and `server.DeserializeAKEState()` directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to incorporate feedback.
// ExpectedMAC returns the expected client MAC if the previous call to Init() was successful. | ||
func (s *Server) ExpectedMAC() []byte { | ||
return s.Ake.ExpectedMAC() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out, for my use case, it's useful to have an accessor for the expected MAC. Without it, I would first need to fetch the server's serialized state from a database, rehydrate it using DeserializeAKEState
, call Finish
, and then make another call to the database to persist an authenticated session.
I do already have SessionKey
, so I could theoretically determine the expected MAC by trimming off SessionKey
as a suffix from the output of SerializeState
; what's left is the MAC. But that's breaking the abstraction.
By adding this accessor, I can make a single call to the database (in a transaction) to assert that the MAC I have from the client matches the expected MAC, and persist an authenticated session.
Co-authored-by: Daniel Bourdrez <3641580+bytemare@users.noreply.github.com>
0fff5ee
to
7943262
Compare
One more thing, and I think we're good to go ! Can you add relevant tests in |
I see some linting complaints when I run
Should I address those? |
7bee4aa
to
b5715f2
Compare
I excluded some linters from running in the internal packages, as there is a lot of code that is still subject to change, and I don't consider some results as a priority (e.g. variables and functions that are not exported outside OPAQUE don't need to be included in the external documentation). But if you're motivated to address them, go for it! ) |
Makes sense. I might circle back to that in a later PR. For now, it looks like all of the CI checks are happy except for Snyk, which is asking for a refreshed auth token. |
Yeah, let's not care about that right now |
Thank you for your contribution ❤️ |
Hey @everyCTO, FYI I took some time to add the comments to the internal package. Your linter should now complain a bit less :) I also extended the test you added to include the case of an existing state for the server. |
This is an implementation of the request in #7. Please refer to that discussion for background.
Changes in
tests/opaque_test.go
are from the discussion and are not meant to make any material change to the test.The focus of this PR is adding two new methods to
ake.Server
:Example usage from the modified test: