Bouncy Castle不在linux机器上工作

时间:2017-12-13 14:49:01

标签: java linux windows bouncycastle fips

我为fips投诉签名生成和验证实现了boucnyCastle,这在windows环境中运行良好,但在linux环境中代码卡在密钥对生成上。以下是我写的代码:

public static KeyPair generateKeyPair() throws GeneralSecurityException
{
    KeyPairGenerator keyPair = KeyPairGenerator.getInstance("RSA", "BCFIPS");
    keyPair.initialize(new RSAKeyGenParameterSpec(3072, RSAKeyGenParameterSpec.F4));
    return keyPair.generateKeyPair();
}

Bouncy Castle

1 个答案:

答案 0 :(得分:3)

首先检查您的系统上是否正在运行rngd.service(硬件RNG熵收集器守护程序)。如果您使用的是虚拟机,则它将无法运行并使用以下链接进行修复:

http://wiki.networksecuritytoolkit.org/index.php/HowTo_Fix_The_rngd.service

使用命令检查您的系统是否有足够的熵:

  

cat / proc / sys / kernel / random / entropy_avail

如果你的系统的熵没有足够的熵,那么增加它。您可以使用以下链接:

https://redhatlinux.guru/index.php/2016/04/03/increase-system-entropy-on-rhel-centos-6-and-7/

在您的系统上安装Haveged以生成人工熵。要安装Haveged,您可以使用 以下链接:

https://www.digitalocean.com/community/tutorials/how-to-setup-additional-entropy-for-cloud-servers-using-haveged