Class RSACore
- java.lang.Object
-
- es.gob.jmulticard.jse.provider.rsacipher.RSACore
-
final class RSACore extends java.lang.Object
Operaciones con claves privadas RSA. No se soporta CRT (Chinese Remainder Theorem). Esta clase no realiza rellenos, estos deben hacerse externamente. Nota: Las claves RSA deben ser de al menos 512 bits.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
RSACore.BlindingParameters
Set of blinding parameters for a given RSA key.private static class
RSACore.BlindingRandomPair
Parameters (u,v) for RSA Blinding.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.math.BigInteger,RSACore.BlindingParameters>
BLINDING_CACHE
private static boolean
ENABLE_BLINDING
-
Constructor Summary
Constructors Modifier Constructor Description private
RSACore()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static byte[]
convert(byte[] b, int ofs, int len)
private static byte[]
crypt(byte[] msg, java.math.BigInteger n, java.math.BigInteger exp)
Operación general de cifrado RSA (unmodPow()
).private static RSACore.BlindingRandomPair
getBlindingRandomPair(java.math.BigInteger e, java.math.BigInteger d, java.math.BigInteger n)
(package private) static int
getByteLength(java.math.BigInteger b)
Return the number of bytes required to store the magnitude byte[] of this BigInteger.(package private) static int
getByteLength(java.security.interfaces.RSAKey key)
Devuelve el número de octetos necesarios para almacenar el módulo de una clave RSA.private static java.math.BigInteger
parseMsg(byte[] msg, java.math.BigInteger n)
Parse the msg into a BigInteger and check against the modulus n.private static byte[]
priCrypt(byte[] msg, java.math.BigInteger n, java.math.BigInteger exp)
RSA non-CRT private key operations.(package private) static byte[]
rsa(byte[] msg, java.security.interfaces.RSAPrivateKey key)
Ejecuta un cifrado RSA con una clave privada.(package private) static byte[]
rsa(byte[] msg, java.security.interfaces.RSAPublicKey key)
Ejecuta un cifrado RSA con una clave pública.private static byte[]
toByteArray(java.math.BigInteger bi, int len)
Return the encoding of this BigInteger that is exactly len bytes long.
-
-
-
Field Detail
-
ENABLE_BLINDING
private static final boolean ENABLE_BLINDING
- See Also:
- Constant Field Values
-
BLINDING_CACHE
private static final java.util.Map<java.math.BigInteger,RSACore.BlindingParameters> BLINDING_CACHE
-
-
Method Detail
-
getByteLength
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
static int getByteLength(java.security.interfaces.RSAKey key)
Devuelve el número de octetos necesarios para almacenar el módulo de una clave RSA.- Parameters:
key
- Clave RSA.- Returns:
- Número de octetos necesarios para almacenar el módulo de la clave proporcionada.
-
convert
static byte[] convert(byte[] b, int ofs, int len)
-
rsa
static byte[] rsa(byte[] msg, java.security.interfaces.RSAPublicKey key) throws javax.crypto.BadPaddingException
Ejecuta un cifrado RSA con una clave pública.- Throws:
javax.crypto.BadPaddingException
-
rsa
static byte[] rsa(byte[] msg, java.security.interfaces.RSAPrivateKey key) throws javax.crypto.BadPaddingException, CryptoCardException, PinException, LostChannelException
Ejecuta un cifrado RSA con una clave privada.- Throws:
LostChannelException
- Si la clave es de un DNIe y se ha perdido el canal seguro.PinException
- Si la clave es de un DNIe y el PIN introducido es inválido.CryptoCardException
- Si la clave es de un DNIe y hay problemas con la tarjeta.javax.crypto.BadPaddingException
-
crypt
private static byte[] crypt(byte[] msg, java.math.BigInteger n, java.math.BigInteger exp) throws javax.crypto.BadPaddingException
Operación general de cifrado RSA (unmodPow()
).- Throws:
javax.crypto.BadPaddingException
-
priCrypt
private static byte[] priCrypt(byte[] msg, java.math.BigInteger n, java.math.BigInteger exp) throws javax.crypto.BadPaddingException
RSA non-CRT private key operations.- Throws:
javax.crypto.BadPaddingException
-
parseMsg
private static java.math.BigInteger parseMsg(byte[] msg, java.math.BigInteger n) throws javax.crypto.BadPaddingException
Parse the msg into a BigInteger and check against the modulus n.- Throws:
javax.crypto.BadPaddingException
-
toByteArray
private static byte[] toByteArray(java.math.BigInteger bi, int len)
Return the encoding of this BigInteger that is exactly len bytes long. Prefix/strip off leading 0x00 bytes if necessary. Precondition: bi must fit into len bytes.
-
getBlindingRandomPair
private static RSACore.BlindingRandomPair getBlindingRandomPair(java.math.BigInteger e, java.math.BigInteger d, java.math.BigInteger n)
-
-