RSA破解作业

Alice decides to use RSA with the public key N = 1889570071. In order to guard against transmission errors, Alice has Bob encrypt his message twice, once using the encryption exponent e1 = 1021763679 and once using the encryption exponent e2 = 519424709. Eve intercepts the two encrypted messages
c1 = 1244183534 and c2 = 732959706. Assuming that Eve also knows N and the two encryption exponents e1 and e2. Please help Eve recover Bob’s plaintext without finding a factorization of N.

选做,交电子版,写成md文档,交链接。提示:简单题,不同于共用模数攻击。

易得:

gcd(e1,e2)=1

则存在一对正反整数s1、s2使得:

e1s1+e2s2=1

由egcd可求出s1、s2:

def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

s1=252426389
s2=496549570

公式变换:

c1=me1modN
c2=me2modN
cs11cs22=(me1modN)s1(me2modN)s2
(cs11cs22)modN=((me1modN)s1(me2modN)s2)modN
(cs11cs22)modN=((me1)s1(me2)s2)modN
(cs11cs22)modN=(me1s1+e2s2)modN

由前面的 e1s1+e2s2=1 得:

(cs11cs22)modN=(m1)modN

由RSA的解密公式可得 m<N ,所以

(cs11cs22)modN=m

最后就用快速幂取模算法求解: (cs11cs22)modN

def fastExpMod(b, e, m):
    result = 1
    while e != 0:
        if (e&1) == 1:
            result = (result * b) % m
        e >>= 1
        b = (b*b) % m
    return result

需要注意:显然用快速幂取模算法不能直接算负数次幂,因此需要先求 c2N

cs22modN=(c12)s2modN

最后求得:

cs11modN=1031756109
cs22modN=603385073
m=(cs11modNcs22modN)modN=1054592380

ps:不是很懂题目提示说的:不同于共模攻击

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值