com.ibm.crypto.fips.provider
Class RSACore
- java.lang.Object
-
- com.ibm.crypto.fips.provider.RSACore
-
public final class RSACore extends java.lang.Object
Core of the RSA implementation. Has code to perform public and private key RSA operations (with and without CRT for private key ops). Private CRT ops also support blinding to twart timing attacks. The code in this class only does the core RSA operation. Padding and unpadding must be done externally. Note: RSA keys should be at least 512 bits long- Since:
- 1.5
-
-
Method Summary
Methods Modifier and Type Method and Description static byte[]
convert(byte[] b, int ofs, int len)
static int
getByteLength(java.math.BigInteger b)
Return the number of bytes required to store the magnitude byte[] of this BigInteger.static int
getByteLength(java.security.interfaces.RSAKey key)
Return the number of bytes required to store the modulus of this RSA key.static byte[]
rsa(byte[] msg, java.security.interfaces.RSAPrivateKey key)
Deprecated.static byte[]
rsa(byte[] msg, java.security.interfaces.RSAPrivateKey key, boolean verify)
Perform an RSA private key operation.static byte[]
rsa(byte[] msg, java.security.interfaces.RSAPublicKey key)
Perform an RSA public key operation.
-
-
-
Method Detail
-
getByteLength
public static int getByteLength(java.math.BigInteger b)
Return the number of bytes required to store the magnitude byte[] of this BigInteger. Do not count a 0x00 byte toByteArray() would prefix for 2's complement form.
-
getByteLength
public static int getByteLength(java.security.interfaces.RSAKey key)
Return the number of bytes required to store the modulus of this RSA key.
-
convert
public static byte[] convert(byte[] b, int ofs, int len)
-
rsa
public static byte[] rsa(byte[] msg, java.security.interfaces.RSAPublicKey key) throws javax.crypto.BadPaddingException
Perform an RSA public key operation.- Throws:
javax.crypto.BadPaddingException
-
rsa
@Deprecated public static byte[] rsa(byte[] msg, java.security.interfaces.RSAPrivateKey key) throws javax.crypto.BadPaddingException
Deprecated.Perform an RSA private key operation. Uses CRT if the key is a CRT key with additional verification check after the signature is computed.- Throws:
javax.crypto.BadPaddingException
-
rsa
public static byte[] rsa(byte[] msg, java.security.interfaces.RSAPrivateKey key, boolean verify) throws javax.crypto.BadPaddingException
Perform an RSA private key operation. Uses CRT if the key is a CRT key. Set 'verify' to true if this function is used for generating a signature.- Throws:
javax.crypto.BadPaddingException
-
-