Skip to content
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

crypto/subtle: No Constant Time Comparison For int64 #36064

Open
InnovativeInventor opened this issue Dec 10, 2019 · 2 comments
Open

crypto/subtle: No Constant Time Comparison For int64 #36064

InnovativeInventor opened this issue Dec 10, 2019 · 2 comments
Labels
FeatureRequest NeedsDecision

Comments

@InnovativeInventor
Copy link

@InnovativeInventor InnovativeInventor commented Dec 10, 2019

Several well-used programs in Golang use int64 as an identifier, but do not use constant time comparison when authenticating. This could be used to leak information to an adversary (potentially). Unfortunately, crypto/subtle does not have a constant-time comparison algorithm for int64, which would clearly be useful to have.

I do not have a clear understanding of how things work "under the hood" in Golang, so I do not trust myself to write a proper constant time int64 comparison algorithm for crypto/subtle. However, I think one could be easily implemented/adapted.

@FiloSottile @rsc @agl It looks like you guys know what you're doing on crypto/subtle. Could you help out here?

@randall77
Copy link
Contributor

@randall77 randall77 commented Dec 10, 2019

Do you just want eq/neq, or do you need ordering?

For eq/neq ConstantTimeEq(int32(x), int32(y)) & ConstantTimeEq(int32(x>>32), int32(y>>32)) will work.

for ordering, I think (ConstantTimeLessOrEq(int32(x>>32), int32(y>>32)) & ^ConstantTimeEq(int32(x>>32),int32(y>>32))) | (ConstantTimeEq(int32(x>>32),int32(y>>32)) & ConstantTimeLessOrEq(int32(x), int32(y))) might work.

@ALTree ALTree added FeatureRequest NeedsDecision labels Dec 10, 2019
@InnovativeInventor
Copy link
Author

@InnovativeInventor InnovativeInventor commented Dec 10, 2019

Eq/neq is all I need (sorry for being ambiguous).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest NeedsDecision
Projects
None yet
Development

No branches or pull requests

3 participants