RSA Public exponent defaults to 65537. What should this value be? What are the impacts of my choices?

荒凉一梦 提交于 2019-12-05 20:45:36
goodguys_activate

Thanks to @BrettHale I was able to solve the issue.

This is how to create a key pair in Bouncy Castle

      // Create key
        RsaKeyPairGenerator generator = new RsaKeyPairGenerator();

        /*
         * This value should be a Fermat number. 0x10001 (F4) is current recommended value. 3 (F1) is known to be safe also.
         * 3, 5, 17, 257, 65537, 4294967297, 18446744073709551617,
         * 
         * Practically speaking, Windows does not tolerate public exponents which do not fit in a 32-bit unsigned integer. Using e=3 or e=65537 works "everywhere". 
         */
        BigInteger exponentBigInt = new BigInteger(exponent.ToString());

        var param = new RsaKeyGenerationParameters(
            exponentBigInt, // new BigInteger("10001", 16)  publicExponent
            new SecureRandom(),  // SecureRandom.getInstance("SHA1PRNG"),//prng
            keyStrength, //strength
            certaninty);//certainty
        generator.Init(param);

Additional links that relate to his recommendation to use RSAKeyGenerationParameters include:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!