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

HS algo verification should use constant time comparison #24

Closed
davedoesdev opened this issue Mar 10, 2015 · 4 comments
Closed

HS algo verification should use constant time comparison #24

davedoesdev opened this issue Mar 10, 2015 · 4 comments

Comments

@davedoesdev
Copy link
Contributor

https://github.com/kjur/jsjws/blob/master/jws-3.0.js#L505

to prevent timing attacks.

@davedoesdev davedoesdev changed the title HS algo verifification should use constant time comparison HS algo verification should use constant time comparison Mar 10, 2015
@davedoesdev
Copy link
Contributor Author

@kjur looks like this is still present in jsrsasign?

https://github.com/kjur/jsrsasign/blob/master/src/jws-3.3.js#L484

@kjur
Copy link
Owner

kjur commented Jul 12, 2017

Hi, how can I fix this?

@davedoesdev
Copy link
Contributor Author

Hi @kjur - what about something like this?

// from https://github.com/goinstant/buffer-equal-constant-time/blob/master/index.js
var const_time_equal = function (s1, s2)
{
    "use strict";
    if (s1.length !== s2.length)
    {
        return false;
    }
    var i, c = 0;
    for (i = 0; i < s1.length; i += 1)
    {
        /*jslint bitwise: true */
        c |= s1.charCodeAt(i) ^ s2.charCodeAt(i); // XOR
        /*jslint bitwise: false */
    }
    return c === 0;
};

@davedoesdev
Copy link
Contributor Author

Closed in favour of kjur/jsrsasign#309

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

No branches or pull requests

2 participants