Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Compare HMACs with MessageDigest to avoid timing attacks #1054

Merged
merged 2 commits into from Apr 14, 2022

Conversation

lavanyaharinarayan
Copy link
Contributor

String.equals is vulnerable to timing attacks.

@CLAassistant
Copy link

CLAassistant commented Apr 14, 2022

CLA assistant check
All committers have signed the CLA.

@coveralls
Copy link

coveralls commented Apr 14, 2022

Coverage Status

Coverage increased (+0.01%) to 76.834% when pulling 4664a4e on lavanya/VULN-62783/hmac-timing-attack into 8fc9cd8 on master.

*
* Uses MessageDigest to prevent timing attacks.
* */
public boolean compareHmacs(String left, String right) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know Java well, so I might be totally off base here, but can/should this method be static since it doesn't need to use any of the class members?

@lavanyaharinarayan lavanyaharinarayan merged commit 1a35a2e into master Apr 14, 2022
@lavanyaharinarayan lavanyaharinarayan deleted the lavanya/VULN-62783/hmac-timing-attack branch April 14, 2022 22:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants