use of org.openecard.common.sal.protocol.exception.ProtocolException in project open-ecard by ecsec.
the class TerminalAuthentication method mseSetAT.
/**
* Initializes the Terminal Authentication protocol.
* Sends an MSE:Set AT APDU. (Protocol step 2)
* See BSI-TR-03110, version 2.10, part 3, B.11.1.
*
* @param oID Terminal Authentication object identifier
* @param chr Certificate Holder Reference (CHR)
* @param key Ephemeral public key
* @param aad Authenticated Auxiliary Data (AAD)
* @throws ProtocolException
*/
public void mseSetAT(byte[] oID, byte[] chr, byte[] key, byte[] aad) throws ProtocolException {
try {
CardCommandAPDU mseSetAT = new MSESetATTA(oID, chr, key, aad);
mseSetAT.transmit(dispatcher, slotHandle);
} catch (APDUException e) {
throw new ProtocolException(e.getResult());
}
}
use of org.openecard.common.sal.protocol.exception.ProtocolException in project open-ecard by ecsec.
the class TerminalAuthentication method verifyCertificates.
/**
* Verify certificates.
* Sends an MSE:Set DST APDU and PSO:Verify Certificate APDU per certificate. (Protocol step 1)
* See BSI-TR-03110, version 2.10, part 3, B.11.4.
* See BSI-TR-03110, version 2.10, part 3, B.11.5.
*
* @param certificateChain Certificate chain
* @throws ProtocolException
*/
public void verifyCertificates(CardVerifiableCertificateChain certificateChain) throws ProtocolException {
try {
for (CardVerifiableCertificate cvc : certificateChain.getCertificates()) {
// MSE:SetDST APDU
CardCommandAPDU mseSetDST = new MSESetDST(cvc.getCAR().toByteArray());
mseSetDST.transmit(dispatcher, slotHandle);
// PSO:Verify Certificate APDU
CardCommandAPDU psovc = new PSOVerifyCertificate(cvc.getCertificate().getValue());
psovc.transmit(dispatcher, slotHandle);
}
} catch (APDUException e) {
throw new ProtocolException(e.getResult());
}
}
use of org.openecard.common.sal.protocol.exception.ProtocolException in project open-ecard by ecsec.
the class ChipAuthentication method mseSetAT.
/**
* Initializes the Chip Authentication protocol.
* Sends an MSE:Set AT APDU. (Protocol step 1)
* See BSI-TR-03110, version 2.10, part 3, B.11.1.
*
* @param oID Chip Authentication object identifier
* @param keyID Key identifier
* @throws ProtocolException
*/
public void mseSetAT(byte[] oID, byte[] keyID) throws ProtocolException {
try {
CardCommandAPDU mseSetAT = new MSESetATCA(oID, keyID);
mseSetAT.transmit(dispatcher, slotHandle);
} catch (APDUException e) {
throw new ProtocolException(e.getResult());
}
}
use of org.openecard.common.sal.protocol.exception.ProtocolException in project open-ecard by ecsec.
the class ChipAuthentication method readEFCardSecurity.
/**
* Reads the EFCardSecurity from the card.
*
* @return EFCardSecurtiy
* @throws ProtocolException Thrown in case there is a problem reading the file.
*/
public byte[] readEFCardSecurity() throws ProtocolException {
try {
byte[] file = ShortUtils.toByteArray(EACConstants.EF_CARDSECURITY_FID);
CardResponseAPDU resp = CardUtils.selectFileWithOptions(dispatcher, slotHandle, file, null, CardUtils.FCP_RESPONSE_DATA);
FCP efCardSecurityFCP = new FCP(TLV.fromBER(resp.getData()));
byte[] efCardSecurity = CardUtils.readFile(efCardSecurityFCP, dispatcher, slotHandle);
return efCardSecurity;
} catch (APDUException ex) {
throw new ProtocolException(ex.getResult());
} catch (TLVException ex) {
throw new ProtocolException("Failed to parse FCP.", ex);
}
}
use of org.openecard.common.sal.protocol.exception.ProtocolException in project open-ecard by ecsec.
the class ChipAuthentication method generalAuthenticate.
/**
* Performs a General Authenticate.
* Sends an General Authenticate APDU. (Protocol step 2)
* See BSI-TR-03110, version 2.10, part 3, B.11.2.
*
* @param key Ephemeral Public Key
* @return Response APDU
* @throws ProtocolException
*/
public byte[] generalAuthenticate(byte[] key) throws ProtocolException {
try {
if (key[0] != (byte) 0x04) {
key = ByteUtils.concatenate((byte) 0x04, key);
}
CardCommandAPDU generalAuthenticate = new GeneralAuthenticate((byte) 0x80, key);
CardResponseAPDU response = generalAuthenticate.transmit(dispatcher, slotHandle);
return response.getData();
} catch (APDUException e) {
throw new ProtocolException(e.getResult());
}
}
Aggregations