public abstract class BaseCard extends java.lang.Object implements CryptoCard, SecureCard
SecureCard.CHANNEL_TYPE
Modifier and Type | Field and Description |
---|---|
protected ApduConnection |
_connection |
protected SignatureNotification |
_signatureNotification |
protected static Location |
CDF_LOCATION |
protected static byte[] |
CERT_ICC_FILE_ID
Identificador del fichero del certificado de componente del DNIe.
|
protected CryptoHelper |
cryptoHelper
Manejador de funciones criptograficas.
|
protected static Location |
DODF_LOCATION |
protected static byte[] |
EF_ATR_2F03
Identificador del fichero de ATR 2F03.
|
protected static byte[] |
ESIGN_FILE |
protected static java.lang.String |
FAST_MODE_PROPERTY
Propiedad del sistema que determina si el "Modo rápido" estáa activado.
|
protected java.security.cert.X509Certificate |
intermediateCaCerICC |
protected Logger |
logger |
protected SecureCard.CHANNEL_TYPE |
m_channelEstablished |
protected static byte[] |
MASTER_FILE_NAME
Nombre del Master File del DNIe.
|
protected static Location |
PRKDF_LOCATION |
protected static byte[] |
REF_RCA_ICC_PUBLIC_KEY
Identificador del fichero del certificado de CA intermedia de componente del DNIe.
|
protected boolean |
TEST_VERSION
Carga de claves REALES o versión PREPRO
|
Modifier | Constructor and Description |
---|---|
protected |
BaseCard(ApduConnection conn,
CryptoHelper cryptoHelper,
SignatureNotification signatureNotification) |
Modifier and Type | Method and Description |
---|---|
protected static byte[] |
deflate(byte[] compressedCertificate)
Descomprime un certificado contenido en el DNIe.
|
protected void |
establishChannel(SecureCard.CHANNEL_TYPE channelType,
boolean restore)
Monta canal de usuario para poder realizar operacions de firma
|
boolean |
externalAuthentication(byte[] extAuthenticationData) |
abstract java.lang.String[] |
getAliases()
Obtiene los alias de los certificados de la tarjeta.
|
protected abstract void |
getCertificateObjects(Cdf cdf,
boolean readBinaryFromPath) |
byte[] |
getChallenge()
Lanza un desafio a la tarjeta para obtener un array de 8 bytes aleatorios.
|
ApduConnection |
getConnection() |
byte[] |
getIccCertEncoded() |
byte[] |
getInternalAuthenticateMessage(byte[] randomIfd,
byte[] chrCCvIfd)
SecureConnection interface methods
|
protected abstract void |
getPrivateKeyObjects(PrKdf prKdf) |
static java.lang.String |
getSCardType(ApduConnection connection)
static methods
|
protected byte[] |
getSerialNumber(int CLA)
Recupera el número de serie
|
protected void |
initialize() |
protected abstract boolean |
isSecurityChannelOpen() |
static byte[] |
readBinary(byte msbOffset,
byte lsbOffset,
byte readLength,
ApduConnection connection)
Lee un contenido binario del fichero actualmente seleccionado.
|
protected static byte[] |
readBinaryComplete(int len,
ApduConnection connection)
Lee por completo el contenido binario del fichero actualmente seleccionado.
|
protected byte[] |
selectCompressedFileByLocationAndRead(Location location)
Selecciona un fichero comprimido y lee los bytes escritos
|
protected static int |
selectFileById(byte[] id,
ApduConnection connection)
Selecciona un fichero (DF o EF).
|
protected byte[] |
selectFileByIdAndRead(byte[] id)
Selecciona un fichero y lo lee por completo.
|
protected byte[] |
selectFileByLocationAndRead(Location location)
Selecciona un fichero y lo lee por completo.
|
protected static void |
selectFileByName(byte[] name,
ApduConnection connection)
Selecciona un fichero por nombre.
|
protected void |
selectMasterFile() |
void |
setKeysToAuthentication(byte[] refPublicKey,
byte[] refPrivateKey,
byte[] auxData) |
protected void |
setPublicKeyToVerification(byte[] refPublicKey)
Establece una clave pública para la la verificación posterior de
un certificado emitido por otro al que pertenece esta clave.
|
protected byte[] |
signOperation(byte[] digestInfo,
PrivateKeyReference privateKeyReference,
boolean confirm,
boolean isAuthCert)
Realiza la operación de firma.
|
boolean |
verifyAge() |
protected void |
verifyCertificate(byte[] cert)
Verifica un certificado en base a una clave pública cargada anteriormente
y que deberá ser la del certificado a partir del cual se generó el
certificado que ahora se valida.
|
protected void |
verifyCertificate(byte[] cert,
boolean isVersion2)
EAC2 DNIe 4.0
|
void |
verifyIcc() |
void |
verifyPin()
Verifica el PIN de la tarjeta.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCACertificates, getCertificate, getPrivateKey, sign
getChrCCvIfd, getIfdPrivateKey, getRefIccPrivateKey, getSerialNumber, verifyCaIntermediateIcc, verifyIfdCertificateChain
protected ApduConnection _connection
protected SignatureNotification _signatureNotification
protected final Logger logger
protected static final byte[] CERT_ICC_FILE_ID
protected static final byte[] REF_RCA_ICC_PUBLIC_KEY
protected static final byte[] EF_ATR_2F03
protected java.security.cert.X509Certificate intermediateCaCerICC
protected CryptoHelper cryptoHelper
protected static final byte[] MASTER_FILE_NAME
protected static final Location CDF_LOCATION
protected static final Location DODF_LOCATION
protected static final Location PRKDF_LOCATION
protected static final java.lang.String FAST_MODE_PROPERTY
protected boolean TEST_VERSION
protected SecureCard.CHANNEL_TYPE m_channelEstablished
protected static final byte[] ESIGN_FILE
protected BaseCard(ApduConnection conn, CryptoHelper cryptoHelper, SignatureNotification signatureNotification)
conn
- cryptoHelper
- public ApduConnection getConnection()
protected void initialize()
protected static byte[] readBinaryComplete(int len, ApduConnection connection) throws java.io.IOException
len
- Longitud del fichero a leerApduConnectionException
- Si hay problemas en el envío de la APDUjava.io.IOException
- Si hay problemas en el buffer de lecturapublic static byte[] readBinary(byte msbOffset, byte lsbOffset, byte readLength, ApduConnection connection) throws ApduConnectionException
msbOffset
- Octeto más significativo del desplazamiento
(offset) hasta el punto de inicio de la lectura desde
el comienzo del ficherolsbOffset
- Octeto menos significativo del desplazamiento (offset)
hasta el punto de inicio de la lectura desde el comienzo del
ficheroreadLength
- Longitud de los datos a leer (en octetos)ApduConnectionException
- Si hay problemas en el envío de la APDUprotected static void selectFileByName(byte[] name, ApduConnection connection) throws ApduConnectionException, FileNotFoundException
name
- Nombre del ficheroFileNotFoundException
- Si el ficheo no existeApduConnectionException
- Si ocurre algún problema durante la selecciónprotected static int selectFileById(byte[] id, ApduConnection connection) throws ApduConnectionException
id
- Identificador del fichero a seleccionarApduConnectionException
- Si hay problemas en el envío de la APDUprotected byte[] selectFileByIdAndRead(byte[] id) throws java.io.IOException
id
- Identificador del fichero a leerApduConnectionException
- Si hay problemas en el envío de la APDUjava.io.IOException
- Si hay problemas en el buffer de lecturaprotected byte[] selectFileByLocationAndRead(Location location) throws java.io.IOException
location
- Ruta absoluta del fichero a leerApduConnectionException
- Si hay problemas en el envío de la APDUjava.io.IOException
- Si falla la selección de fichero o hay problemas en el buffer de lecturaprotected byte[] selectCompressedFileByLocationAndRead(Location location) throws java.io.IOException
location
- Ruta absoluta del fichero a leerApduConnectionException
- Si hay problemas en el envío de la APDUjava.io.IOException
- Si falla la selección de fichero o hay problemas en el buffer de lecturaprotected void setPublicKeyToVerification(byte[] refPublicKey) throws SecureChannelException, ApduConnectionException, java.io.IOException
refPublicKey
- Referencia a la clave pública para su carga.SecureChannelException
- Cuando ocurre un error durante la selección de la clave.ApduConnectionException
- Cuando ocurre un error en la comunicación con la tarjeta.java.io.IOException
public byte[] getChallenge() throws ApduConnectionException
getChallenge
in interface SecureCard
ApduConnectionException
- Cuando ocurre un error en la comunicación con la tarjeta.public void verifyPin() throws ApduConnectionException
RuntimeException
o una ApduConnectionException
.ApduConnectionException
- Cuando ocurre un error en la comunicación con la tarjeta.AuthenticationModeLockedException
- Si está bloqueada la verificación de PIN (por ejemplo, por superar
el número máximo de intentos)public boolean verifyAge() throws ApduConnectionException
ApduConnectionException
protected abstract void getPrivateKeyObjects(PrKdf prKdf)
prKdf
- protected abstract void getCertificateObjects(Cdf cdf, boolean readBinaryFromPath) throws java.lang.RuntimeException
cdf
- java.lang.RuntimeException
protected byte[] getSerialNumber(int CLA) throws ApduConnectionException
ApduConnectionException
- Si la conexión con la tarjeta se proporciona cerrada y no es posible abrirlapublic abstract java.lang.String[] getAliases()
CryptoCard
getAliases
in interface CryptoCard
protected void selectMasterFile() throws ApduConnectionException, FileNotFoundException
protected static byte[] deflate(byte[] compressedCertificate) throws java.io.IOException
compressedCertificate
- Certificado comprimido en ZIP a partir del 9 byte.java.io.IOException
- Cuando se produce un error en la descompresion del certificado.protected abstract boolean isSecurityChannelOpen()
protected void establishChannel(SecureCard.CHANNEL_TYPE channelType, boolean restore) throws CryptoCardException
CryptoCardException
- Cuando se produce un error en la operación con la tarjetaprotected byte[] signOperation(byte[] digestInfo, PrivateKeyReference privateKeyReference, boolean confirm, boolean isAuthCert) throws CryptoCardException
digestInfo
- Información para la firma.privateKeyReference
- Referencia a la clave privada para la firma.CryptoCardException
- Cuando se produce un error durante la operación de firma.AuthenticationModeLockedException
- Cuando el DNIe está bloqueado.protected void verifyCertificate(byte[] cert) throws ApduConnectionException
cert
- Certificado que se desea comprobarSecureChannelException
- Cuando el certificado no es correcto u ocurre algún error en la validaciónApduConnectionException
- Cuando ocurre un error en la comunicación con la tarjetaprotected void verifyCertificate(byte[] cert, boolean isVersion2) throws ApduConnectionException
cert
- ApduConnectionException
public byte[] getInternalAuthenticateMessage(byte[] randomIfd, byte[] chrCCvIfd) throws ApduConnectionException
getInternalAuthenticateMessage
in interface SecureCard
ApduConnectionException
public boolean externalAuthentication(byte[] extAuthenticationData) throws ApduConnectionException
externalAuthentication
in interface SecureCard
extAuthenticationData
- Mensaje de autenticación externaApduConnectionException
public void setKeysToAuthentication(byte[] refPublicKey, byte[] refPrivateKey, byte[] auxData) throws ApduConnectionException
setKeysToAuthentication
in interface SecureCard
ApduConnectionException
public byte[] getIccCertEncoded() throws java.io.IOException
getIccCertEncoded
in interface SecureCard
java.io.IOException
public void verifyIcc() throws java.io.IOException
verifyIcc
in interface SecureCard
java.io.IOException
public static java.lang.String getSCardType(ApduConnection connection)