use of org.openecard.common.tlv.TLV in project open-ecard by ecsec.
the class EF_AODTest method readEF_AOD.
@Test
public void readEF_AOD() throws TLVException, IOException {
TLV tlv = ReadHelper.readCIAFile("EF_AOD.bin");
AuthenticationObjectChoice pkc = new AuthenticationObjectChoice(tlv);
}
use of org.openecard.common.tlv.TLV in project open-ecard by ecsec.
the class EF_CDTest method readEF_CD.
@Test
public void readEF_CD() throws TLVException, IOException {
TLV tlv = ReadHelper.readCIAFile("EF_CD.bin");
CertificateChoice pkc = new CertificateChoice(tlv);
}
use of org.openecard.common.tlv.TLV in project open-ecard by ecsec.
the class EF_CIAInfoTest method readEF_CIAInfo.
@Test
public void readEF_CIAInfo() throws TLVException, IOException {
TLV tlv = ReadHelper.readCIAFile("EF_CIAInfo.bin");
CIAInfo ciaInfo = new CIAInfo(tlv);
}
use of org.openecard.common.tlv.TLV in project open-ecard by ecsec.
the class EF_PrKDTest method readEF_PrKD.
@Test
public void readEF_PrKD() throws TLVException, IOException {
TLV tlv = ReadHelper.readCIAFile("EF_PrKD.bin");
PrivateKeyChoice pkc = new PrivateKeyChoice(tlv);
}
use of org.openecard.common.tlv.TLV in project open-ecard by ecsec.
the class CardVerifiableCertificateVerifier method verify.
/**
* Verifies that the certificate description matches the certificate.
* Verification is done by hashing the description and comparing it
* to the checksum containing in the certificate extention.
* See BSI-TR-03110, version 2.10, part 3, section C.3.
*
* @param certificate Certificate
* @param description Description
* @throws CertificateException
*/
public static void verify(CardVerifiableCertificate certificate, CertificateDescription description) throws CertificateException {
try {
byte[] extentions = certificate.getExtensions();
TLV extentionObject = TLV.fromBER(extentions);
List<TLV> list = extentionObject.asList();
for (TLV item : list) {
String oid = ObjectIdentifierUtils.toString(item.getValue());
if (oid.equals(CVCertificatesObjectIdentifier.id_description)) {
List<TLV> hashObjects = item.findChildTags(0x80);
if (hashObjects != null && !hashObjects.isEmpty()) {
TLV hashObject = hashObjects.get(0);
MessageDigest md = selectDigest(certificate.getPublicKey().getObjectIdentifier());
byte[] hash = md.digest(description.getEncoded());
if (!ByteUtils.compare(hash, hashObject.getValue())) {
throw new CertificateException("The checksum of the certificate description cannot be verified!");
}
}
} else if (oid.equals(CVCertificatesObjectIdentifier.id_sector)) {
List<TLV> firstPublicKeyObjects = item.findChildTags(0x80);
if (firstPublicKeyObjects != null && !firstPublicKeyObjects.isEmpty()) {
TLV firstPublicKeyObject = firstPublicKeyObjects.get(0);
// TODO
}
List<TLV> secondPublicKeyObjects = item.findChildTags(0x81);
if (secondPublicKeyObjects != null && !secondPublicKeyObjects.isEmpty()) {
TLV secondPublicKeyObject = secondPublicKeyObjects.get(0);
// TODO
}
} else {
_logger.warn("Unknown OID: {} ", oid);
}
}
} catch (Exception e) {
_logger.debug(e.getMessage());
throw new CertificateException("Verification failed", e);
}
}
Aggregations