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

GCD with Even modulus #590

Open
pinkforest opened this issue Apr 5, 2024 · 0 comments
Open

GCD with Even modulus #590

pinkforest opened this issue Apr 5, 2024 · 0 comments

Comments

@pinkforest
Copy link

pinkforest commented Apr 5, 2024

NIST.SP.800-56Br2 - Appendix C.2 - Deterministic Prime-Factor Recovery

The second part would require GCD(modulus - 1, public * private exp - 1)

1. Let a = (de – 1) × GCD(n – 1, de – 1).

This leads the modulus to be Even - https://github.com/RustCrypto/RSA/pull/394/files#r1553034591

However Bernstein-Yang (BY) GCD has a tripwire for left side to be Odd:

impl Gcd for BoxedUint {
    type Output = CtOption<Self>;

    fn gcd(&self, rhs: &Self) -> CtOption<Self> {
        let ret = bernstein_yang::boxed::gcd(self, rhs);
        CtOption::new(ret, self.is_odd())
    }
}

BearSSL Trick

Footnote 4. in bigint

Except at some point in RSA key pair generation, where we must invert the public exponent e modulo both p−1 and q−1, which are even. For that operation, BearSSL must employ additional tricks.

Go also seems to use the same "Extended Binary" GCD - by Thomas Pornin -

https://github.com/pornin/bingcd | https://eprint.iacr.org/2020/972.pdf | ncc

Go has report 3.3.2 for Inversion for both Even and Odd with "a standard trick" applied to calculate 𝑥−1 mod 𝑚

𝑢 := 𝑚−1 mod 𝑥 using odd moduli + um - 1 / x

https://cronokirby.com/papers/2021/06/bsc_report.pdf

Other related:

Yaoan Jin & Atsuko Miyaji - CT-GCD work if BY-GCD is not an option for Even modulus ?

Also Hamburg has a paper -https://eprint.iacr.org/2021/1271.pdf re: Jacobi & Bernstein-Yang

"It assumes that the given y is odd, which is often the case in cryptography; if y is not odd, the algorithm first divides out powers of 2 from y and/or x until y is odd"

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

1 participant