【发布时间】:2012-01-30 07:32:29
【问题描述】:
各位,我最近在 PC 和 Android 上实现了 RSA 加密。有些在 PC (jdk1.6) 上运行良好,但是当我在 Android 上尝试时(Android 2.1 with jdk1.5 strong>),莫名其妙出现错误。
代码如下:
BigInteger m = m;
BigInteger e = e;
RSAPublicKeySpec keySpec = new RSAPublicKeySpec(m, e);
KeyFactory fact = KeyFactory.getInstance("RSA");
try{
PublicKey pubKey = fact.generatePublic(keySpec);
return pubKey;
} catch (Exception e) {
throw new RuntimeException("Spurious serialisation error", e);
}
return null;
问题是 PublicKey pubKey = fact.generatePublic(keySpec); 好像引起了异常,但是抓不到,甚至修改为Throwable e .它只是跳转到 return null; 但实际上返回值不是 null,它是一个非法的 Pubkey,具有正常的指数(65537)和一个坏的模数(用大量字母填充,'ae3432a** *'。
谁能帮我测试一下?
【问题讨论】: