Example usage for org.bouncycastle.asn1 ASN1Sequence getObjectAt

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

Introduction

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

Prototype

public ASN1Encodable getObjectAt(int index) 

Source Link

Document

Return the object at the sequence position indicated by index.

Usage

From source file:edu.tamu.tcat.crypto.bouncycastle.ASN1SeqKeyImpl.java

License:Apache License

private static PrivateKey decodeECKey(byte[] encodedKey) throws EncodingException {
    try {//from  w ww.  j a  v a2  s  .  c  o m
        ECPrivateKey priv = ECPrivateKey.getInstance(encodedKey);
        ASN1Sequence parameters = (ASN1Sequence) priv.getParameters();

        ASN1Integer version = (ASN1Integer) parameters.getObjectAt(0);
        if (version.getPositiveValue().intValue() != 1)
            throw new EncodingException("Only know how to decode version 1");
        ASN1Sequence fieldId = (ASN1Sequence) parameters.getObjectAt(1);
        ASN1Encodable fieldType = fieldId.getObjectAt(0);
        ECField field;
        if (fieldType.toString().equals("1.2.840.10045.1.1")) {
            ASN1Integer primeObject = (ASN1Integer) fieldId.getObjectAt(1);
            field = new ECFieldFp(primeObject.getPositiveValue());
        } else
            throw new EncodingException("Only know how to decode prime fields");
        ASN1Sequence curveSeq = (ASN1Sequence) parameters.getObjectAt(2);

        ASN1OctetString a = (ASN1OctetString) curveSeq.getObjectAt(0);
        ASN1OctetString b = (ASN1OctetString) curveSeq.getObjectAt(1);
        EllipticCurve curve;
        if (curveSeq.size() > 2) {
            DERBitString seed = (DERBitString) curveSeq.getObjectAt(2);
            curve = new EllipticCurve(field, getInteger(a.getOctets()), getInteger(b.getOctets()),
                    seed.getBytes());
        } else
            curve = new EllipticCurve(field, getInteger(a.getOctets()), getInteger(b.getOctets()));

        ASN1OctetString gEncoded = (ASN1OctetString) parameters.getObjectAt(3);
        ECPoint g = ECPointUtil.decodePoint(curve, gEncoded.getOctets());
        ASN1Integer n = (ASN1Integer) parameters.getObjectAt(4);
        ASN1Integer h = (ASN1Integer) parameters.getObjectAt(5);
        ECParameterSpec paramSpec = new ECParameterSpec(curve, g, n.getPositiveValue(),
                h.getPositiveValue().intValue());

        ECPrivateKeySpec spec = new ECPrivateKeySpec(priv.getKey(), paramSpec);
        KeyFactory factory = KeyFactory.getInstance("EC", Activator.getDefault().getBouncyCastleProvider());
        PrivateKey key = factory.generatePrivate(spec);
        return key;
    } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
        throw new EncodingException("Failed decoding type [EC]", e);
    }
}

From source file:edu.vt.middleware.crypt.io.PrivateKeyCredentialReader.java

License:Open Source License

/** {@inheritDoc} */
protected PrivateKey decode(final byte[] encoded) throws CryptException {
    final KeySpec spec;
    final String algorithm;

    final ASN1Object o;
    try {/*from  w  ww .  j a  v  a  2  s . c  om*/
        o = ASN1Object.fromByteArray(encoded);
    } catch (Exception e) {
        throw new CryptException("Key is not ASN.1 encoded data.");
    }

    // Assume PKCS#8 and try OpenSSL "traditional" format as backup
    PrivateKeyInfo pi;
    try {
        pi = PrivateKeyInfo.getInstance(o);
    } catch (Exception e) {
        pi = null;
    }
    if (pi != null) {
        final String algOid = pi.getAlgorithmId().getObjectId().getId();
        if (RSA_ID.equals(pi.getAlgorithmId().getObjectId())) {
            algorithm = "RSA";
        } else if (EC_ID.equals(pi.getAlgorithmId().getObjectId())) {
            algorithm = "EC";
        } else if (DSA_ID.equals(pi.getAlgorithmId().getObjectId())) {
            algorithm = "DSA";
        } else {
            throw new CryptException("Unsupported PKCS#8 algorithm ID " + algOid);
        }
        try {
            spec = new PKCS8EncodedKeySpec(encoded);
        } catch (Exception e) {
            throw new CryptException("Invalid PKCS#8 private key format.", e);
        }
    } else if (o instanceof DERObjectIdentifier) {
        // Indicates we have an EC key in the default OpenSSL format emitted by
        //
        // openssl ecparam -name xxxx -genkey
        //
        // which is the concatenation of the named curve OID and a sequence of 1
        // containing the private point
        algorithm = "EC";

        final DERObjectIdentifier oid = (DERObjectIdentifier) o;
        final int len = encoded[1];
        final byte[] privatePart = new byte[encoded.length - len - 2];
        System.arraycopy(encoded, len + 2, privatePart, 0, privatePart.length);
        try {
            final ASN1Sequence seq = (ASN1Sequence) ASN1Sequence.fromByteArray(privatePart);
            spec = new ECPrivateKeySpec(DERInteger.getInstance(seq.getObjectAt(0)).getValue(),
                    ECUtils.fromNamedCurve(oid));
        } catch (IOException e) {
            throw new CryptException("Error reading elliptic curve key data.", e);
        }
    } else {
        // OpenSSL "traditional" format is an ASN.1 sequence of key parameters

        // Detect key type based on number and types of parameters:
        // RSA -> {version, mod, pubExp, privExp, prime1, prime2, exp1, exp2, c}
        // DSA -> {version, p, q, g, pubExp, privExp}
        // EC ->  {version, privateKey, parameters, publicKey}
        final DERSequence sequence = (DERSequence) o;
        if (sequence.size() == 9) {
            if (logger.isDebugEnabled()) {
                logger.debug("Reading OpenSSL format RSA private key.");
            }
            algorithm = "RSA";
            try {
                spec = new RSAPrivateCrtKeySpec(DERInteger.getInstance(sequence.getObjectAt(1)).getValue(),
                        DERInteger.getInstance(sequence.getObjectAt(2)).getValue(),
                        DERInteger.getInstance(sequence.getObjectAt(3)).getValue(),
                        DERInteger.getInstance(sequence.getObjectAt(4)).getValue(),
                        DERInteger.getInstance(sequence.getObjectAt(5)).getValue(),
                        DERInteger.getInstance(sequence.getObjectAt(6)).getValue(),
                        DERInteger.getInstance(sequence.getObjectAt(7)).getValue(),
                        DERInteger.getInstance(sequence.getObjectAt(8)).getValue());
            } catch (Exception e) {
                throw new CryptException("Invalid RSA key.", e);
            }
        } else if (sequence.size() == 6) {
            if (logger.isDebugEnabled()) {
                logger.debug("Reading OpenSSL format DSA private key.");
            }
            algorithm = "DSA";
            try {
                spec = new DSAPrivateKeySpec(DERInteger.getInstance(sequence.getObjectAt(5)).getValue(),
                        DERInteger.getInstance(sequence.getObjectAt(1)).getValue(),
                        DERInteger.getInstance(sequence.getObjectAt(2)).getValue(),
                        DERInteger.getInstance(sequence.getObjectAt(3)).getValue());
            } catch (Exception e) {
                throw new CryptException("Invalid DSA key.", e);
            }
        } else if (sequence.size() == 4) {
            if (logger.isDebugEnabled()) {
                logger.debug("Reading OpenSSL format EC private key.");
            }
            algorithm = "EC";
            spec = ECUtils.readEncodedPrivateKey(sequence);
        } else {
            throw new CryptException("Invalid OpenSSL traditional private key format.");
        }
    }
    try {
        return CryptProvider.getKeyFactory(algorithm).generatePrivate(spec);
    } catch (InvalidKeySpecException e) {
        throw new CryptException("Invalid key specification", e);
    }
}

From source file:edu.vt.middleware.crypt.io.PublicKeyCredentialReader.java

License:Open Source License

/** {@inheritDoc} */
protected PublicKey decode(final byte[] encoded) throws CryptException {
    try {/*from www  .  ja  va 2s  . c o m*/
        final ASN1Sequence seq = (ASN1Sequence) ASN1Object.fromByteArray(encoded);
        final ASN1Sequence innerSeq = (ASN1Sequence) seq.getObjectAt(0);
        final DEREncodable algId = innerSeq.getObjectAt(0);
        final String algorithm;
        if (RSA_ID.equals(algId)) {
            algorithm = "RSA";
        } else if (EC_ID.equals(algId)) {
            algorithm = "EC";
        } else if (DSA_ID.equals(algId)) {
            algorithm = "DSA";
        } else {
            throw new CryptException("Unsupported public key algorithm ID " + algId);
        }
        return CryptProvider.getKeyFactory(algorithm).generatePublic(new X509EncodedKeySpec(encoded));
    } catch (Exception e) {
        throw new CryptException("Invalid public key.", e);
    }
}

From source file:edu.vt.middleware.crypt.signature.AbstractDSASignature.java

License:Open Source License

/**
 * Produces the r,s integer pair of a DSA signature from a DER-encoded byte
 * representation./*w w  w  .  j  a v  a 2  s .c o m*/
 *
 * @param  in  DER-encoded concatenation of byte representation of r and s.
 *
 * @return  DSA signature output parameters (r,s).
 *
 * @throws  edu.vt.middleware.crypt.CryptException  On cryptographic errors.
 */
private BigInteger[] decode(final byte[] in) throws CryptException {
    ASN1Sequence s;
    try {
        s = (ASN1Sequence) new ASN1InputStream(in).readObject();
    } catch (IOException e) {
        throw new CryptException("Error decoding DSA signature.", e);
    }
    return new BigInteger[] { ((DERInteger) s.getObjectAt(0)).getValue(),
            ((DERInteger) s.getObjectAt(1)).getValue(), };
}

From source file:edu.vt.middleware.crypt.util.ECUtils.java

License:Open Source License

/**
 * Reads a ASN.1 encoded EC private key according the structure defined in
 * sections C.4 and C.2 of SEC 1: Elliptic Curve Cryptography,
 * www.secg.org/collateral/sec1_final.pdf.
 *
 * @param  seq  ASN.1 encoded sequence of EC private key parameters.
 *
 * @return  Constructed EC key parameter specification.
 *///from  ww w .  j a v  a2  s  . co m
public static ECPrivateKeySpec readEncodedPrivateKey(final ASN1Sequence seq) {
    final BigInteger s = DERInteger.getInstance(seq.getObjectAt(1)).getValue();
    final ASN1TaggedObject params = DERTaggedObject.getInstance(seq.getObjectAt(2));
    return new ECPrivateKeySpec(s, readEncodedParams((ASN1Sequence) params.getObject()));
}

From source file:edu.vt.middleware.crypt.x509.ExtensionFactory.java

License:Open Source License

/**
 * Creates a {@link PolicyInformationList} object from DER data.
 *
 * @param  enc  DER encoded policy information data; must be <code>
 * ASN1Sequence</code>.//from   w  w  w. j a v  a 2s. c o m
 *
 * @return  Certificate policy information listing.
 */
public static PolicyInformationList createPolicyInformationList(final DEREncodable enc) {
    if (!(enc instanceof ASN1Sequence)) {
        throw new IllegalArgumentException("Expected ASN1Sequence but got " + enc);
    }

    final ASN1Sequence seq = (ASN1Sequence) enc;
    final List<PolicyInformation> policies = new ArrayList<PolicyInformation>(seq.size());
    for (int i = 0; i < seq.size(); i++) {
        policies.add(createPolicyInformation(seq.getObjectAt(i)));
    }
    return new PolicyInformationList(policies.toArray(new PolicyInformation[policies.size()]));
}

From source file:edu.vt.middleware.crypt.x509.ExtensionFactory.java

License:Open Source License

/**
 * Creates a {@link PolicyInformation} object from DER data.
 *
 * @param  enc  DER encoded policy information data.
 *
 * @return  Certificate policy information object.
 */// ww  w .  j  a  va2  s.  c o  m
public static PolicyInformation createPolicyInformation(final DEREncodable enc) {
    final org.bouncycastle.asn1.x509.PolicyInformation info = org.bouncycastle.asn1.x509.PolicyInformation
            .getInstance(enc);
    final ASN1Sequence encodedQualifiers = info.getPolicyQualifiers();
    if (encodedQualifiers != null) {
        final int size = encodedQualifiers.size();
        final List<PolicyQualifierInfo> qualifiers = new ArrayList<PolicyQualifierInfo>(size);
        for (int i = 0; i < size; i++) {
            final DEREncodable item = encodedQualifiers.getObjectAt(i);
            qualifiers.add(createPolicyQualifierInfo(item));
        }
        return new PolicyInformation(info.getPolicyIdentifier().toString(),
                qualifiers.toArray(new PolicyQualifierInfo[size]));
    } else {
        return new PolicyInformation(info.getPolicyIdentifier().toString());
    }
}

From source file:edu.vt.middleware.crypt.x509.ExtensionFactory.java

License:Open Source License

/**
 * Creates a {@link DistributionPointList} object from DER data.
 *
 * @param  enc  DER encoded distribution point list.
 *
 * @return  List of CRL distribution points.
 *///  ww  w.j  a va 2  s. c o m
public static DistributionPointList createDistributionPointList(final DEREncodable enc) {
    if (!(enc instanceof ASN1Sequence)) {
        throw new IllegalArgumentException("Expected ASN1Sequence but got " + enc);
    }

    final ASN1Sequence seq = (ASN1Sequence) enc;
    final List<DistributionPoint> distPoints = new ArrayList<DistributionPoint>();
    for (int i = 0; i < seq.size(); i++) {
        final org.bouncycastle.asn1.x509.DistributionPoint dp = org.bouncycastle.asn1.x509.DistributionPoint
                .getInstance(seq.getObjectAt(i));
        Object name = null;
        if (dp.getDistributionPoint() != null) {
            if (dp.getDistributionPoint()
                    .getType() == org.bouncycastle.asn1.x509.DistributionPointName.FULL_NAME) {
                name = createGeneralNameList(dp.getDistributionPoint().getName());
            } else {
                name = dp.getDistributionPoint().toString();
            }
        }

        ReasonFlags reasons = null;
        if (dp.getReasons() != null) {
            reasons = new ReasonFlags(dp.getReasons().getBytes());
        }

        GeneralNameList issuer = null;
        if (dp.getCRLIssuer() != null) {
            issuer = createGeneralNameList(dp.getCRLIssuer());
        }
        if (name instanceof GeneralNameList) {
            distPoints.add(new DistributionPoint((GeneralNameList) name, reasons, issuer));
        } else {
            distPoints.add(new DistributionPoint((String) name, reasons, issuer));
        }
    }
    return new DistributionPointList(distPoints);
}

From source file:edu.vt.middleware.crypt.x509.types.RelativeDistinguishedName.java

License:Open Source License

/**
 * Creates a new instance from an ASN.1 SET of SEQUENCE representing the
 * AttributeTypeAndValue type of section 2 of RFC 2253.
 *
 * @param  set  Set from which to create new RDN instance.
 *
 * @return  New RDN from encoded data.//from w  w w .j a v  a  2s  .co m
 */
public static RelativeDistinguishedName fromASN1Set(final ASN1Set set) {
    final List<AttributeTypeAndValue> values = new ArrayList<AttributeTypeAndValue>();
    for (int i = 0; i < set.size(); i++) {
        final DEREncodable value = set.getObjectAt(i);
        if (!(value instanceof ASN1Sequence)) {
            throw new IllegalArgumentException("Value must be ASN.1 sequence.");
        }

        final ASN1Sequence seq = (ASN1Sequence) value;
        if (seq.size() != 2) {
            throw new IllegalArgumentException("Illegal sequence size " + seq.size());
        }
        if (!(seq.getObjectAt(0) instanceof DERObjectIdentifier)) {
            throw new IllegalArgumentException("First sequence item must be OID.");
        }
        values.add(new AttributeTypeAndValue(seq.getObjectAt(0).toString(), seq.getObjectAt(1).toString()));
    }
    return new RelativeDistinguishedName(values);
}

From source file:es.gob.afirma.applet.CMSInformation.java

License:Open Source License

/**
 * Obtiene la informaci&oacute;n de diferentes tipos de formatos.
 * @param doj Etiqueta ASN.1 de la que se obtienen los datos.
 * @param envelopeType   Tipo de formato:
 * <li>0: EnvelopedData</li>
 * <li>1: AuthenticatedData</li>
 * <li>2: AuthEnvelopedData</li>
 * <li>3: SignedAndEnvelopedData</li>
 * <li>4: SignedData</li>/*from   www .jav  a  2 s . co  m*/
 * <li>5: Encrypted</li>
 * @param tipoDetalle   Tipo de datos (literal)
 * @param signBinaryType Tipo de firmado binario (CADES o CMS)
 * @return  Representaci&oacute;n de los datos.
 */
private static String extractData(final ASN1TaggedObject doj, final int envelopeType, final String tipoDetalle,
        final int signBinaryType) {
    String detalle = ""; //$NON-NLS-1$
    detalle = detalle + tipoDetalle + CR;

    ASN1Set rins = null;
    EncryptedContentInfo encryptedContentInfo = null;
    ASN1Set unprotectedAttrs = null;
    ASN1Integer version = null;
    AlgorithmIdentifier aid = null;
    ContentInfo ci = null;
    ASN1Set authAttrs = null;
    ASN1Set ds = null;
    ASN1Set signerInfosSd = null;

    switch (envelopeType) {
    case TYPE_ENVELOPED_DATA:
        final EnvelopedData enveloped = EnvelopedData.getInstance(doj.getObject());
        version = enveloped.getVersion();
        rins = enveloped.getRecipientInfos();
        encryptedContentInfo = enveloped.getEncryptedContentInfo();
        unprotectedAttrs = enveloped.getUnprotectedAttrs();
        break;
    case TYPE_AUTHENTICATED_DATA:
        final AuthenticatedData authenticated = AuthenticatedData.getInstance(doj.getObject());
        version = authenticated.getVersion();
        rins = authenticated.getRecipientInfos();
        aid = authenticated.getMacAlgorithm();
        ci = authenticated.getEncapsulatedContentInfo();
        authAttrs = authenticated.getAuthAttrs();
        unprotectedAttrs = authenticated.getUnauthAttrs();
        break;
    case TYPE_AUTHENTICATED_ENVELOPED_DATA:
        final AuthEnvelopedData authEnveloped = AuthEnvelopedData.getInstance(doj.getObject());
        version = authEnveloped.getVersion();
        rins = authEnveloped.getRecipientInfos();
        encryptedContentInfo = authEnveloped.getAuthEncryptedContentInfo();
        authAttrs = authEnveloped.getAuthAttrs();
        unprotectedAttrs = authEnveloped.getUnauthAttrs();
        break;
    case TYPE_SIGNED_ENVELOPED_DATA:
        final SignedAndEnvelopedData signedEnv = new SignedAndEnvelopedData((ASN1Sequence) doj.getObject());
        version = signedEnv.getVersion();
        rins = signedEnv.getRecipientInfos();
        encryptedContentInfo = signedEnv.getEncryptedContentInfo();
        signerInfosSd = signedEnv.getSignerInfos();
        break;
    case TYPE_SIGNED_DATA:
        final SignedData signed = SignedData.getInstance(doj.getObject());
        version = signed.getVersion();
        ds = signed.getDigestAlgorithms();
        ci = signed.getEncapContentInfo();
        signerInfosSd = signed.getSignerInfos();
        break;
    case TYPE_ENCRYPTED_DATA:
        final ASN1Sequence encrypted = (ASN1Sequence) doj.getObject();
        version = ASN1Integer.getInstance(encrypted.getObjectAt(0));
        encryptedContentInfo = EncryptedContentInfo.getInstance(encrypted.getObjectAt(1));
        if (encrypted.size() == 3) {
            unprotectedAttrs = (ASN1Set) encrypted.getObjectAt(2);
        }
        break;
    default:
        throw new IllegalArgumentException("Tipo de sobre no soportado: " + envelopeType); //$NON-NLS-1$
    }

    //obtenemos la version
    detalle = detalle + AppletMessages.getString("CMSInformation.1") + SP + version + CR; //$NON-NLS-1$

    //recipientInfo
    if (rins != null) {
        if (envelopeType != TYPE_SIGNED_DATA && envelopeType != TYPE_ENCRYPTED_DATA && rins.size() > 0) {
            detalle = detalle + AppletMessages.getString("CMSInformation.13") + CR; //$NON-NLS-1$
        }
        for (int i = 0; i < rins.size(); i++) {
            final KeyTransRecipientInfo kti = KeyTransRecipientInfo
                    .getInstance(RecipientInfo.getInstance(rins.getObjectAt(i)).getInfo());
            detalle = detalle + AppletMessages.getString("CMSInformation.14") + SP + (i + 1) + ":" + CR; //$NON-NLS-1$//$NON-NLS-2$
            final AlgorithmIdentifier diAlg = kti.getKeyEncryptionAlgorithm();

            //issuer y serial
            final IssuerAndSerialNumber iss = (IssuerAndSerialNumber) SignerIdentifier
                    .getInstance(kti.getRecipientIdentifier().getId()).getId();
            detalle = detalle + TB + AppletMessages.getString("CMSInformation.15") + SP //$NON-NLS-1$
                    + iss.getName().toString() + CR;
            detalle = detalle + TB + AppletMessages.getString("CMSInformation.16") + SP + iss.getSerialNumber() //$NON-NLS-1$
                    + CR;

            // el algoritmo de cifrado de los datos
            AOCipherAlgorithm algorithm = null;
            final AOCipherAlgorithm[] algos = AOCipherAlgorithm.values();

            // obtenemos el algoritmo usado para cifrar la pass
            for (final AOCipherAlgorithm algo : algos) {
                if (algo.getOid().equals(diAlg.getAlgorithm().toString())) {
                    algorithm = algo;
                }
            }
            if (algorithm != null) {
                detalle = detalle + TB + AppletMessages.getString("CMSInformation.17") + SP //$NON-NLS-1$
                        + algorithm.getName() + CR;
            } else {
                detalle = detalle + TB + AppletMessages.getString("CMSInformation.18") + SP //$NON-NLS-1$
                        + diAlg.getAlgorithm() + CR;
            }
        }
    }

    if (envelopeType == TYPE_ENVELOPED_DATA || envelopeType == TYPE_ENCRYPTED_DATA) {
        //obtenemos datos de los datos cifrados.
        detalle = detalle + AppletMessages.getString("CMSInformation.19") + CR; //$NON-NLS-1$
        detalle = detalle + getEncryptedContentInfo(encryptedContentInfo);
    } else if (envelopeType == TYPE_AUTHENTICATED_DATA && aid != null && ci != null) {
        // mac algorithm
        detalle = detalle + AppletMessages.getString("CMSInformation.20") + SP + aid.getAlgorithm() + CR; //$NON-NLS-1$

        //digestAlgorithm
        final ASN1Sequence seq = (ASN1Sequence) doj.getObject();
        final ASN1TaggedObject da = (ASN1TaggedObject) seq.getObjectAt(4);
        final AlgorithmIdentifier dai = AlgorithmIdentifier.getInstance(da.getObject());
        detalle = detalle + AppletMessages.getString("CMSInformation.21") + SP + dai.getAlgorithm() + CR; //$NON-NLS-1$

        //obtenemos datos de los datos cifrados.
        detalle = detalle + AppletMessages.getString("CMSInformation.22") + SP + ci.getContentType() + CR; //$NON-NLS-1$

        detalle = getObligatorieAtrib(signBinaryType, detalle, authAttrs);
    } else if (envelopeType == TYPE_AUTHENTICATED_ENVELOPED_DATA) {
        detalle = detalle + AppletMessages.getString("CMSInformation.19") + CR; //$NON-NLS-1$
        detalle = detalle + getEncryptedContentInfo(encryptedContentInfo);

        detalle = getObligatorieAtrib(signBinaryType, detalle, authAttrs);
    } else if (envelopeType == TYPE_SIGNED_ENVELOPED_DATA) {
        //algoritmo de firma
        final ASN1Sequence seq = (ASN1Sequence) doj.getObject();
        final ASN1Set da = (ASN1Set) seq.getObjectAt(2);
        final AlgorithmIdentifier dai = AlgorithmIdentifier.getInstance(da.getObjectAt(0));
        detalle = detalle + AppletMessages.getString("CMSInformation.21") + SP + dai.getAlgorithm() + CR; //$NON-NLS-1$

        //obtenemos datos de los datos cifrados.
        detalle = detalle + AppletMessages.getString("CMSInformation.19") + CR; //$NON-NLS-1$
        detalle = detalle + getEncryptedContentInfo(encryptedContentInfo);
    } else if (envelopeType == TYPE_SIGNED_DATA && ci != null && ds != null) {
        //algoritmo de firma
        final AlgorithmIdentifier dai = AlgorithmIdentifier.getInstance(ds.getObjectAt(0));
        detalle = detalle + AppletMessages.getString("CMSInformation.21") + SP + dai.getAlgorithm() + CR; //$NON-NLS-1$
        detalle = detalle + AppletMessages.getString("CMSInformation.22") + SP + ci.getContentType() + CR; //$NON-NLS-1$
    }

    //obtenemos lo atributos opcionales
    if (envelopeType != TYPE_SIGNED_ENVELOPED_DATA) {
        if (unprotectedAttrs == null) {
            detalle = detalle + AppletMessages.getString("CMSInformation.28") + CR; //$NON-NLS-1$
        } else {
            final String atributos = getUnSignedAttributes(unprotectedAttrs.getObjects());
            detalle = detalle + AppletMessages.getString("CMSInformation.29") + CR; //$NON-NLS-1$
            detalle = detalle + atributos;
        }
    } else if ((envelopeType == TYPE_SIGNED_ENVELOPED_DATA || envelopeType == TYPE_SIGNED_DATA)
            && signerInfosSd != null) {
        //obtenemos el(los) firmate(s)
        if (signerInfosSd.size() > 0) {
            detalle = detalle + AppletMessages.getString("CMSInformation.30") + CR; //$NON-NLS-1$
        }
        for (int i = 0; i < signerInfosSd.size(); i++) {
            final SignerInfo si = SignerInfo.getInstance(signerInfosSd.getObjectAt(i));

            detalle = detalle + AppletMessages.getString("CMSInformation.31") + SP + (i + 1) + ":" + CR; //$NON-NLS-1$//$NON-NLS-2$
            // version
            detalle = detalle + TB + AppletMessages.getString("CMSInformation.1") + SP + si.getVersion() + CR; //$NON-NLS-1$
            //signerIdentifier
            final SignerIdentifier sident = si.getSID();
            final IssuerAndSerialNumber iss = IssuerAndSerialNumber.getInstance(sident.getId());
            detalle = detalle + TB + AppletMessages.getString("CMSInformation.15") + SP //$NON-NLS-1$
                    + iss.getName().toString() + CR;
            detalle = detalle + TB + AppletMessages.getString("CMSInformation.16") + SP + iss.getSerialNumber() //$NON-NLS-1$
                    + CR;

            //digestAlgorithm
            final AlgorithmIdentifier algId = si.getDigestAlgorithm();
            detalle = detalle + TB + AppletMessages.getString("CMSInformation.35") + SP + algId.getAlgorithm() //$NON-NLS-1$
                    + CR;

            //obtenemos lo atributos obligatorios
            final ASN1Set sa = si.getAuthenticatedAttributes();
            String satributes = ""; //$NON-NLS-1$
            if (sa != null) {
                satributes = getsignedAttributes(sa, signBinaryType);
            }
            detalle = detalle + TB + AppletMessages.getString("CMSInformation.36") + CR; //$NON-NLS-1$
            detalle = detalle + satributes;
        }
    }
    return detalle;
}