镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

RSA CRT parameters? #574

Closed
Closed

Description

@public

AKA dp, dq and qinv.

Should we extend the RSA private key API to include these? Probably both in __init__ as well as getters.

Some probably extremely suspect fors and againsts...

For:

Against:

  • Adds 3 more things to __init__.
  • How do we validate them?
  • Maybe not every RSA implementation actually uses CRT?
  • Not strictly required, (but then we only need p, q, and e anyway.)

Activity

  1. Ivoz commented on Feb 7, 2014

    @Ivoz
    Contributor

    If they're only generated when an RSA private key is instantiated, I don't think it's very slow; certainly not slower than generation of p and q themselves.

    code to generate them is just (assuming an implementation of mod_mul_inv)

        phi = (p - 1) * (q - 1)
        # d = pow(e, phi - 1, phi)
        d = mod_mul_inv(e, phi)
        dp = d % (p - 1)
        dq = d % (q - 1)
        # qinv = pow(q, p - 2, p)
        qinv = mod_mul_inv(q, p)
    def mod_mul_inv(e, m):
        """ Modular Multiplicative Inverse.
            return the value x such that (x*e) mod m == 1 """
        x1, y1, x2, y2 = 1, 0, 0, 1
        a, b = e, m
        while b > 0:
            q, r = divmod(a, b)
            xn, yn = x1 - q * x2, y1 - q * y2
            a, b, x1, y1, x2, y2 = b, r, x2, y2, xn, yn
        return x1 % m
  2. public commented on Feb 7, 2014

    @public
    MemberAuthor

    Caching them on the private key object ourselves is indeed an option too. We need some benchmarks :)

  3. reaperhulk commented on Feb 8, 2014

    @reaperhulk
    Member

    Per discussion in IRC I support adding these values as required parameters to the constructor. We can loosen this restriction in the future if we decide computing these values in Python is permissible/desirable.

  4. added this to the Second Release milestone on Feb 9, 2014
  5. locked as resolved and limited conversation to collaborators on Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions