-
Notifications
You must be signed in to change notification settings - Fork 146
add more compact encoding #72
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
Conversation
Current encoding does Base64 twice against payload because of intermediate text encoding. And it produces too large mac (256bit) while 128bit is more than enough. Add "compact" mode which uses binary encoding for message with single Base64 pass and 128bit hmac output (at max).
Note that any encoding change has the effect of breaking all existing
sessions, as they are no longer compatible.
…On Sun, Jun 28, 2020 at 8:50 PM Sokolov Yura ***@***.***> wrote:
Current encoding does Base64 twice against payload because of intermediate
text encoding. And it produces too large mac (256bit) while 128bit is more
than enough.
Add "compact" mode which uses binary encoding for message with single
Base64 pass and 128bit hmac output (at max).
TestSecureCookie: securecookie_test.go:48: i 0 len 184
TestSecureCookie: securecookie_test.go:48: i 1 len 128
TestSecureCookie: securecookie_test.go:48: i 2 len 188
TestSecureCookie: securecookie_test.go:48: i 3 len 128
TestSecureCookie: securecookie_test.go:48: i 4 len 188
TestSecureCookie: securecookie_test.go:48: i 5 len 128
TestSecureCookie: securecookie_test.go:48: i 6 len 188
TestSecureCookie: securecookie_test.go:48: i 7 len 128
TestSecureCookie: securecookie_test.go:48: i 8 len 188
TestSecureCookie: securecookie_test.go:48: i 9 len 128
------------------------------
You can view, comment on, or merge this pull request online at:
#72
Commit Summary
- add more compact encoding
File Changes
- *M* securecookie.go
<https://github.com/gorilla/securecookie/pull/72/files#diff-c51d3fc36978add43da88584bf60eca6>
(120)
- *M* securecookie_test.go
<https://github.com/gorilla/securecookie/pull/72/files#diff-b1d1c2d21c81de3e631840c495417e79>
(13)
Patch Links:
- https://github.com/gorilla/securecookie/pull/72.patch
- https://github.com/gorilla/securecookie/pull/72.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#72>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAEQ4DOSIJ7C4CTLW4S4ADRZAFPRANCNFSM4OK3XQJA>
.
|
@elithrar that is why current encoding is preserved and remains to be default. |
Probably it will be better to move timestamp backward: currently compact encoded cookie always starts with |
Yeah, changed it to varint, and it doesn't even look weird. |
So, will there be consensus about this feature? Close it or merge it? |
Hmm, looks like there is a way to be backward compatible: if I place 0 byte first (before base64 encoding), then there is clear way to distinguish between compact encoding and text based encoding. I also made such trick to avoid nonce in private repository:
where
I'd like to change this PR this way if you don't mind. |
comparison of such scheme with current secure cookie using NopEncoder on messages 0-250bytes long:
|
close in favor of #73 |
Current encoding does Base64 twice against payload because of intermediate
text encoding. And it produces too large mac (256bit) while 128bit is more
than enough.
Add "compact" mode which uses binary encoding for message with single
Base64 pass and 128bit hmac output (at max).