给定公共和私有指数,如何分解 RSA 模数?
我有一个带有模数 m
、公共指数 e
和私有指数 d
的 RSA 私钥,但我正在使用的程序需要模数的质因数p
和 q
。
是否可以使用e
和d
来获取p
和q
?
I have a RSA private key with modulus m
, public exponent e
and private exponent d
, but the program I am using needs the modulus's prime factors p
and q
.
Is it possible to use e
and d
to get p
and q
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的——一旦您知道模数 N 以及公共/私有指数 d 和 e,获得 p 和 q 使得 N=pq 并不太困难。
Dan Boneh 的这篇论文描述了一种这样做的算法。它依靠的是
事实上,根据定义,
de = 1 mod phi(N)。
对于任何随机选择的“证人”
在 (2,N) 中,大约有 50% 的机会能够使用它来找到一个非平凡的
1 mod N 的平方根(称为 x)。然后 gcd(x-1,N) 给出因子之一。
Yes -- once you know the modulus N, and public/private exponents d and e, it is not too difficult to obtain p and q such that N=pq.
This paper by Dan Boneh describes an algorithm for doing so. It relies
on the fact that, by definition,
de = 1 mod phi(N).
For any randomly chosen "witness"
in (2,N), there is about a 50% chance of being able to use it to find a nontrivial
square root of 1 mod N (call it x). Then gcd(x-1,N) gives one of the factors.
您可以使用我在 2009 年开发的开源工具,该工具可以在 SFM 格式 (n,e,d) 和 CRT 格式 (p,q,dp,dq,u) 之间转换 RSA 密钥,反之亦然。它位于 SourceForge 上: http://rsaconverter.sourceforge.net/
我实现的算法基于提出的想法作者:Dan Boneh,如之前的答案所述。
我希望这会有用。
穆尼尔·伊德拉西 - IDRIX
You can use the open source tool I have developed in 2009 that converts RSA keys between the SFM format (n,e,d) and CRT format (p,q,dp,dq,u), and the other way around. It is on SourceForge : http://rsaconverter.sourceforge.net/
The algorithm I implemented is based on ideas presented by Dan Boneh, as described by the previous answer.
I hope this will be useful.
Mounir IDRASSI - IDRIX
我在加密堆栈交换上发布了一个回复,回答了同样的问题 这里。它使用与 Boneh 论文中概述的相同方法,但对其实际工作原理做了更多解释。我还尝试假设最少的先验知识。
希望这有帮助!
I posted a response on the crypto stack exchange answering the same question here. It uses the same approach as outlined in Boneh's paper, but does a lot more explanation as to how it actually works. I also try to assume a minimal amount of prior knowledge.
Hope this helps!
我努力深入研究 Boneh 的论文。从
(n, d)
导出(p, q)
的“算法”隐藏在第 1.1 节的末尾,用数学术语进行编码,并作为练习留下让读者从他的(相当简洁的)证据中得出这样做是有效的。显然,对于不知道什么的人来说,这几乎毫无意义
$Z_N^\ast $
是,并且具有相当非线性的结构,需要大量时间才能转变为线性算法。所以这是有效的解决方案:
现场演示(JS):
要回答标题中所述的问题:因式分解
N
需要求N
。但是在一般情况下,你不能从(e, d)<导出
N
/代码>。因此,在一般情况下,您无法从
(e, d)
导出N
的因子;量子电子器件。如果您想尝试这样做,您将需要能够分解
e * d - 1
(如果我正确理解上面链接的答案):I put in the effort to dig through Boneh's paper. The "algorithm" for deriving
(p, q)
from(n, d)
is buried at the end of §1.1, coded in maths jargon, and left as an exercise for the reader to render out of his (rather terse) proof that it's efficient to do so.Obviously, this is pretty close to meaningless for anyone who doesn't know what
$Z_N^\ast$
is, and has a pretty nonlinear structure that takes a good deal of time to twist into a linear algorithm.So here is the worked solution:
Live demo (JS):
To answer the question as-stated in the title: factoring
N
entails findingN
. But you cannot, in the general case, deriveN
from(e, d)
. Therefore, you cannot, in the general case, derive the factors ofN
from(e, d)
; QED.If you want to try to do so anyway, you'll need to be able to factorize
e * d - 1
(if I understand the above-linked answer correctly):