Bouncy Castle不在linux机器上工作

我为fips投诉签名生成和validation实现了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(); } 

充气城堡

首先检查您的系统上是否正在运行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