Example usage for org.bouncycastle.asn1 DERSequence getObjectAt

List of usage examples for org.bouncycastle.asn1 DERSequence getObjectAt

Introduction

In this page you can find the example usage for org.bouncycastle.asn1 DERSequence getObjectAt.

Prototype

public ASN1Encodable getObjectAt(int index) 

Source Link

Document

Return the object at the sequence position indicated by index.

Usage

From source file:de.fraunhofer.fokus.openeid.ca.ChipAuthenticationDomainParameterInfo.java

License:Open Source License

public ChipAuthenticationDomainParameterInfo(DERSequence chipDomainParameterInfoSequence)
        throws InvalidDomainParameter {
    DERObjectIdentifier derOid = (DERObjectIdentifier) chipDomainParameterInfoSequence.getObjectAt(0);
    protocolOid = derOid.getId();//  w w w  . j a v a  2 s  .  c o  m
    DERSequence algorithm = (DERSequence) chipDomainParameterInfoSequence.getObjectAt(1);
    AlgorithmIdentifier id = new AlgorithmIdentifier(algorithm);
    int domainParameterValue = ((DERInteger) id.getParameter().get(0)).getValue().intValue();
    domainParameter = StandardizedDomainParameters.getById(domainParameterValue);
    DERInteger derKeyId = (DERInteger) chipDomainParameterInfoSequence.getObjectAt(2);
    keyId = derKeyId.getValue().intValue();

}

From source file:de.fraunhofer.fokus.openeid.ca.ChipAuthenticationInfo.java

License:Open Source License

public ChipAuthenticationInfo(DERSequence chipInfoSequence) {
    DERObjectIdentifier derOid = (DERObjectIdentifier) chipInfoSequence.getObjectAt(0);
    protocolOid = derOid.getId();/*from w  ww. j a va2 s . c o m*/
    DERInteger derVersion = (DERInteger) chipInfoSequence.getObjectAt(1);
    version = derVersion.getValue().intValue();
    if (chipInfoSequence.size() > 2) {
        DERInteger derKeyId = (DERInteger) chipInfoSequence.getObjectAt(2);
        keyId = derKeyId.getValue().intValue();
    }
}

From source file:de.fraunhofer.fokus.openeid.ca.ChipAuthenticationPublicKeyInfo.java

License:Open Source License

public ChipAuthenticationPublicKeyInfo(DERSequence chipInfoSequence) {
    DERObjectIdentifier derOid = (DERObjectIdentifier) chipInfoSequence.getObjectAt(0);
    oid = derOid.getId();/*from w w  w . j a  va 2s  .c  o m*/

    DERSequence publicKey = (DERSequence) chipInfoSequence.getObjectAt(1);

    logger.info(ASN1Dump.dumpAsString(publicKey, true));

    algorithmIdentifier = (DERSequence) publicKey.getObjectAt(0);
    DERBitString encodedKey = (DERBitString) publicKey.getObjectAt(1);
    encodedPublicKey = encodedKey.getBytes();

    if (chipInfoSequence.size() > 2) {
        DERInteger derKeyId = (DERInteger) chipInfoSequence.getObjectAt(2);
        keyId = derKeyId.getValue().intValue();
    }

}

From source file:de.fraunhofer.fokus.openeid.eac.EfFile.java

License:Open Source License

public SignedData getSecurityObject() throws IOException {
    DERSequence fileSequence = (DERSequence) file;
    DERTaggedObject level1 = (DERTaggedObject) fileSequence.getObjectAt(1);
    DERSequence level1_ = (DERSequence) level1.getObject();
    DERSequence level2 = (DERSequence) level1_.getObjectAt(2);
    DERTaggedObject level3 = (DERTaggedObject) level2.getObjectAt(1);
    return new SignedData((DEROctetString) level3.getObject());
}

From source file:de.fraunhofer.fokus.openeid.pace.PACEInfo.java

License:Open Source License

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.
    }//from  ww w  .  j  av a 2s .  com
}

From source file:de.fraunhofer.fokus.openeid.ri.ProtocolParams.java

License:Open Source License

public ProtocolParams(DERSequence sequence) {
    this.version = ((DERInteger) sequence.getObjectAt(0)).getValue().intValue(); // must be 1 (BSI-TR 03110)
    this.keyID = ((DERInteger) sequence.getObjectAt(1)).getValue().intValue();
    this.authorizedOnly = ((DERBoolean) sequence.getObjectAt(2)).isTrue();
}

From source file:de.fraunhofer.fokus.openeid.ri.RestrictedIdentificationDomainParameterInfo.java

License:Open Source License

public RestrictedIdentificationDomainParameterInfo(DERSequence sequence) {
    this.protocol = ((DERObjectIdentifier) sequence.getObjectAt(0)).getId();
    DERSequence algorithm = (DERSequence) sequence.getObjectAt(1);
    this.algorithmIdentifier = new AlgorithmIdentifier(algorithm);
}

From source file:de.fraunhofer.fokus.openeid.ri.RestrictedIdentificationInfo.java

License:Open Source License

public RestrictedIdentificationInfo(DERSequence sequence) {
    DERObjectIdentifier derOid = (DERObjectIdentifier) sequence.getObjectAt(0);
    protocolOid = derOid.getId();//w ww .  j  a v  a2  s.  co  m
    this.protocolParams = new ProtocolParams((DERSequence) sequence.getObjectAt(1));
    if (sequence.size() > 2) {
        this.maxKeyLen = ((DERInteger) sequence.getObjectAt(2)).getValue().intValue();
    }
}

From source file:de.fraunhofer.fokus.openeid.ta.TerminalAuthenticationInfo.java

License:Open Source License

public TerminalAuthenticationInfo(DERSequence terminalInfoSequence) {
    DERObjectIdentifier derOid = (DERObjectIdentifier) terminalInfoSequence.getObjectAt(0);
    protocolOid = derOid.getId();/*from w  ww  . j  a v a 2s. co m*/
    DERInteger derVersion = (DERInteger) terminalInfoSequence.getObjectAt(1);
    version = derVersion.getValue().intValue();
}

From source file:de.thiemann.ssl.report.model.CertificateV3.java

License:Open Source License

private PubKeyInfo transferPublicKeyInfo(byte[] encodedPublicKey) {
    PubKeyInfo info = new PubKeyInfo();

    try {/*from  w w w  .ja  v  a  2 s. co m*/
        SubjectPublicKeyInfo subPubKeyInfo = new SubjectPublicKeyInfo(
                (ASN1Sequence) ASN1Object.fromByteArray(encodedPublicKey));
        String asn1PubKeyId = subPubKeyInfo.getAlgorithmId().getAlgorithm().getId();

        if (asn1PubKeyId.equals(ASN1PublicKeyIds.RSA.getOid())) {
            DERSequence seq = (DERSequence) subPubKeyInfo.getPublicKey();
            ASN1Integer iModulus = (ASN1Integer) seq.getObjectAt(0);
            BigInteger modulus = iModulus.getPositiveValue();

            info.pubKeyAlgorithm = ASN1PublicKeyIds.RSA.name();
            info.pubKeySize = modulus.bitLength();
        } else if (asn1PubKeyId.equals(ASN1PublicKeyIds.DSA.getOid())) {
            info.pubKeyAlgorithm = ASN1PublicKeyIds.DSA.name();
        } else if (asn1PubKeyId.equals(ASN1PublicKeyIds.Diffie_Hellman.getOid())) {
            info.pubKeyAlgorithm = ASN1PublicKeyIds.Diffie_Hellman.name();
        } else if (asn1PubKeyId.equals(ASN1PublicKeyIds.KEA.getOid())) {
            info.pubKeyAlgorithm = ASN1PublicKeyIds.KEA.name();
        } else if (asn1PubKeyId.equals(ASN1PublicKeyIds.ECDH.getOid())) {
            info.pubKeyAlgorithm = ASN1PublicKeyIds.ECDH.name();
        } else
            info.pubKeyAlgorithm = "Unknown public key! OID: " + asn1PubKeyId;

    } catch (IOException e) {
        e.printStackTrace();
    }

    return info;
}