Setting the key size
Hi,
I would like to set the key size for encryption. My code is the following:
privatestaticfinal String algorithm ="RSA/None/NoPadding";
privatestaticfinal String keyAlgorithm ="RSA";
privatestaticfinal String providor ="BC";
privatestatic Cipher cipher =null;
privatestatic KeyFactory keyFactory =null;
privatestatic RSAPublicKeySpec pubKeySpec =null;
privatestatic RSAPrivateKeySpec privKeySpec =null;
privatestatic RSAPublicKey pubKey =null;
privatestatic RSAPrivateKey privKey =null;
static{
Security.addProvider(new BouncyCastleProvider());
try{
cipher = Cipher.getInstance(algorithm, providor);
keyFactory = KeyFactory.getInstance(keyAlgorithm, providor);
BigInteger modulus =new BigInteger("d46f473a2d746537de2056ae3092c451", 16);
BigInteger publicExponent =new BigInteger("11", 16);
BigInteger privateExponent =new BigInteger("57791d5430d593164082036ad8b29fb1", 16);
System.out.println(publicExponent +":" + privateExponent);
pubKeySpec =new RSAPublicKeySpec(modulus, publicExponent);
privKeySpec =new RSAPrivateKeySpec(modulus, privateExponent);
pubKey = (RSAPublicKey) keyFactory.generatePublic(pubKeySpec);
privKey = (RSAPrivateKey) keyFactory.generatePrivate(privKeySpec);
}catch (Throwable t){
t.printStackTrace();
}
}
I imagine that the key size is determined by the modulus, but how do I set it to 1024 rather than the 128 which it now is I presume?
Thanks in advance
Michael

