Java tutorial
/******************************************************************************* * Implementation of the protocols PACE, Terminal Authentication and Chip * Authentication (client side) with respect to the according BSI standards. * * Copyright (C) 2013 Fraunhofer-Gesellschaft * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package de.fraunhofer.fokus.openeid.pace; import org.bouncycastle.asn1.DERInteger; import org.bouncycastle.asn1.DERObjectIdentifier; import org.bouncycastle.asn1.DERSequence; import de.fraunhofer.fokus.openeid.commands.UnsupportedProtocolException; /** * * Relevant information for PACE, * which can be read out from EF.CardAccess * * * @author "Mateusz Khalil" * */ public class PACEInfo { public PACEInfo(DERSequence paceInfoSequence) throws UnsupportedProtocolException, InvalidDomainParameter { DERObjectIdentifier derOid = (DERObjectIdentifier) paceInfoSequence.getObjectAt(0); protocol = PACEInfoProtocol.getProtocolByOid(derOid.getId()); DERInteger derVersion = (DERInteger) paceInfoSequence.getObjectAt(1); version = derVersion.getValue().intValue(); if (paceInfoSequence.size() == 3) { //parameterId is OPTIONAL DERInteger derParameter = (DERInteger) paceInfoSequence.getObjectAt(2); int parameterId = derParameter.getValue().intValue(); domainParameter = StandardizedDomainParameters.getById(parameterId); //TODO there could be non-standardized DomainParameters defined -> @see TR-03110 A.2.1 / A.2.1.1. } } /** pace version */ private int version; /** optional standardized domain parameter */ private StandardizedDomainParameters domainParameter; /** oid defining security parameters */ private PACEInfoProtocol protocol; @Override public String toString() { return "Version:" + version + "\nDomainParameter:" + domainParameter + "\nProtocolInfo" + protocol.toString(); } public int getVersion() { return version; } public StandardizedDomainParameters getDomainParameter() { return domainParameter; } public PACEInfoProtocol getProtocol() { return protocol; } }