当hash很大时,Mpz_powm给出了错误的答案?

时间:2016-11-02 15:57:54

标签: rsa gmp mod

我现在处于试错阶段,因此我为变量分配了一些小数字,因为我知道计算是正确的。

在我的加密功能中,我有了这个功能;

hexValues = 65;
d = 2753;
n = 3233;
mpz_powm(sigfile, hexValues, d, n); //sigfile = hexvalues^d % n = 588

上面的power mod函数给我的值为588

在我的解密功能中

sigfile = 588; //this is where i read sigfile value from encryption function
e = 17;
N = 3233;
mpz_powm(answer, sigfile, e, N); //answer = sigfile^e %N

显然我得到65,因为我只对数字应用反向公式。

但问题是,如果我将hexValues(65)从加密更改为6555,我将从两个函数中得到不同的结果。

更不用说用实际的哈希值来测试它了。

加密6555作为哈希值会给我2448但是Decryption给了我89.

*这是一项任务。

*是的,变量是用mpz数据类型初始化的。

0 个答案:

没有答案
相关问题