Example usage for org.bouncycastle.asn1 DEROctetString DEROctetString

List of usage examples for org.bouncycastle.asn1 DEROctetString DEROctetString

Introduction

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

Prototype

public DEROctetString(ASN1Encodable obj) throws IOException 

Source Link

Document

Constructor from the encoding of an ASN.1 object.

Usage

From source file:es.gob.afirma.envelopers.cades.CAdESUtils.java

License:Open Source License

/** Obtiene la estructura ASN.1 de firma usando los atributos del firmante.
 * @param signatureAlgorithm/*from  www. ja va2s  .  c o  m*/
 *        Algoritmo para la firma
 * @param keyEntry
 *        Clave para firmar.
 * @param signedAttr2
 *        Atributos firmados
 * @return Firma de los atributos.
 * @throws AOException
 *         si ocurre cualquier error durante la firma */
static ASN1OctetString firma(final String signatureAlgorithm, final PrivateKeyEntry keyEntry,
        final ASN1Set signedAttr2) throws AOException {

    final Signature sig;
    try {
        sig = Signature.getInstance(signatureAlgorithm);
    } catch (final Exception e) {
        throw new AOException("Error obteniendo la clase de firma para el algoritmo " + signatureAlgorithm, e); //$NON-NLS-1$
    }

    final byte[] tmp;
    try {
        tmp = signedAttr2.getEncoded(ASN1Encoding.DER);
    } catch (final IOException ex) {
        throw new AOException("Error obteniendo el contenido a firmar", ex); //$NON-NLS-1$
    }

    // Indicar clave privada para la firma
    try {
        sig.initSign(keyEntry.getPrivateKey());
    } catch (final Exception e) {
        throw new AOException("Error al inicializar la firma con la clave privada", e); //$NON-NLS-1$
    }

    // Actualizamos la configuracion de firma
    try {
        sig.update(tmp);
    } catch (final SignatureException e) {
        throw new AOException("Error al configurar la informacion de firma", e); //$NON-NLS-1$
    }

    // firmamos.
    final byte[] realSig;
    try {
        realSig = sig.sign();
    } catch (final Exception e) {
        throw new AOException("Error durante el proceso de firma", e); //$NON-NLS-1$
    }

    return new DEROctetString(realSig);
}

From source file:es.gob.afirma.envelopers.cms.CMSAuthenticatedData.java

License:Open Source License

/** Genera una estructura PKCS#7 <code>AuthenticatedData</code>.
 * @param parameters Par&aacute;metros necesarios que contienen tanto la firma del
 *                    archivo a firmar como los datos del firmante.
 * @param signerCertChain Cadena de certificados del firmante.
 * @param autenticationAlgorithm Algoritmo para los codigos de autenticaci&oacute;n MAC
 * @param config Configuraci&oacute;n del algoritmo para firmar
 * @param certDest Certificado del destino al cual va dirigido la firma.
 * @param dataType Identifica el tipo del contenido a firmar.
 * @param applyTimestamp Si se aplica el Timestamp o no.
 * @param atrib Atributos firmados opcionales.
 * @param uatrib Atributos no autenticados firmados opcionales.
 * @param keySize Tama&ntilde;o de la clave AES.
 * @return Firma de tipo AuthenticatedData.
 * @throws IOException Si ocurre alg&uacute;n problema leyendo o escribiendo los
 *                     datos/*  w  w w. jav a  2  s.  co m*/
 * @throws CertificateEncodingException Si se produce alguna excepci&oacute;n con los certificados de
 *                                      firma.
 * @throws NoSuchAlgorithmException Si no se encuentra un algoritmo v&aacute;lido.
 * @throws InvalidKeyException Cuando hay problemas de adecuaci&oacute;n de la clave.
 * @throws BadPaddingException Cuando hay problemas con un relleno de datos.
 * @throws IllegalBlockSizeException Cuando hay problemas internos con los tama&ntilde;os de bloque de cifrado.
 * @throws InvalidAlgorithmParameterException Si no se soporta un par&aacute;metro necesario para un algoritmo.
 * @throws NoSuchPaddingException Cuando no se soporta un tipo de relleno necesario. */
static byte[] genAuthenticatedData(final P7ContentSignerParameters parameters,
        final X509Certificate[] signerCertChain, final String autenticationAlgorithm,
        final AOCipherConfig config, final X509Certificate[] certDest, final String dataType,
        final boolean applyTimestamp, final Map<String, byte[]> atrib, final Map<String, byte[]> uatrib,
        final Integer keySize) throws IOException, CertificateEncodingException, NoSuchAlgorithmException,
        InvalidKeyException, NoSuchPaddingException, InvalidAlgorithmParameterException,
        IllegalBlockSizeException, BadPaddingException {

    final SecretKey cipherKey = Utils.initEnvelopedData(config, keySize);

    // Ya que el contenido puede ser grande, lo recuperamos solo una vez
    final byte[] content2 = parameters.getContent();

    // 1. ORIGINATORINFO
    // obtenemos la lista de certificados
    final ASN1Set certificates = Utils.fetchCertificatesList(signerCertChain);
    ASN1Set certrevlist = null;

    OriginatorInfo origInfo = null;
    if (signerCertChain.length != 0) {
        // introducimos una lista vacia en los CRL ya que no podemos
        // modificar el codigo de bc.
        final List<ASN1Encodable> crl = new ArrayList<ASN1Encodable>();
        certrevlist = SigUtils.createBerSetFromList(crl);
        origInfo = new OriginatorInfo(certificates, certrevlist);
    }

    // 2. RECIPIENTINFOS
    final Info infos = Utils.initVariables(content2, config, certDest, cipherKey);

    // 3. MACALGORITHM
    final AlgorithmIdentifier macAlgorithm = SigUtils.makeAlgId(config.getAlgorithm().getOid());

    // 4. DIGESTALGORITMIDENTIFIER
    final String digestAlgorithm = AOSignConstants.getDigestAlgorithmName(parameters.getSignatureAlgorithm());
    final AlgorithmIdentifier digAlgId = SigUtils.makeAlgId(AOAlgorithmID.getOID(digestAlgorithm));

    // 5. ENCAPSULATEDCONTENTINFO

    // si se introduce el contenido o no

    ContentInfo encInfo = null;
    final ASN1ObjectIdentifier contentTypeOID = new ASN1ObjectIdentifier(dataType);
    final ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    final CMSProcessable msg = new CMSProcessableByteArray(content2);
    try {
        msg.write(bOut);
    } catch (final CMSException ex) {
        throw new IOException("Error en la escritura del procesable CMS: " + ex, ex); //$NON-NLS-1$
    }
    encInfo = new ContentInfo(contentTypeOID, new BEROctetString(bOut.toByteArray()));

    // 6. ATRIBUTOS FIRMADOS
    ASN1Set authAttr = null;
    authAttr = generateSignedAtt(signerCertChain[0], digestAlgorithm, content2, dataType, applyTimestamp,
            atrib);

    // 7. MAC
    final byte[] mac = Utils.genMac(autenticationAlgorithm, authAttr.getEncoded(ASN1Encoding.DER), cipherKey);

    // 8. ATRIBUTOS NO FIRMADOS.

    ASN1Set unAuthAttr = null;
    unAuthAttr = Utils.generateUnsignedAtt(uatrib);

    // construimos el Authenticated data y lo devolvemos
    return new ContentInfo(PKCSObjectIdentifiers.id_ct_authData, new AuthenticatedData(origInfo, // OriginatorInfo
            new DERSet(infos.getRecipientInfos()), // ASN1Set
            macAlgorithm, // macAlgorithm
            digAlgId, // AlgorithmIdentifier
            encInfo, // ContentInfo
            authAttr, // ASN1Set
            new DEROctetString(mac), // ASN1OctetString
            unAuthAttr // ASN1Set
    )).getEncoded(ASN1Encoding.DER);

}

From source file:es.gob.afirma.envelopers.cms.CMSAuthenticatedData.java

License:Open Source License

/** M&eacute;todo que genera la parte que contiene la informaci&oacute;n del
 * Usuario. Se generan los atributos que se necesitan para generar la firma.
 * @param cert/* w w  w  . ja  v a2  s  .c  om*/
 *        Certificado necesario para la firma.
 * @param digestAlgorithm
 *        Algoritmo Firmado.
 * @param datos
 *        Datos firmados.
 * @param datatype
 *        Identifica el tipo del contenido a firmar.
 * @param timestamp
 *        Introducir TimeStaming
 * @param atrib
 *        Lista de atributos firmados que se insertar&aacute;n dentro
 *        del archivo de firma.
 * @return Los atributos firmados de la firma.
 * @throws java.security.NoSuchAlgorithmException
 *         Si no se encuentra un algoritmo v&aacute;lido. */
private static ASN1Set generateSignedAtt(final X509Certificate cert, final String digestAlgorithm,
        final byte[] datos, final String datatype, final boolean timestamp, final Map<String, byte[]> atrib)
        throws NoSuchAlgorithmException {

    // // ATRIBUTOS

    // authenticatedAttributes
    final ASN1EncodableVector contexExpecific = new ASN1EncodableVector();

    // tipo de contenido
    contexExpecific
            .add(new Attribute(CMSAttributes.contentType, new DERSet(new ASN1ObjectIdentifier(datatype))));

    // fecha de firma
    if (timestamp) {
        contexExpecific.add(new Attribute(CMSAttributes.signingTime, new DERSet(new DERUTCTime(new Date()))));
    }

    // Si nos viene el hash de fuera no lo calculamos
    final byte[] md = MessageDigest.getInstance(AOSignConstants.getDigestAlgorithmName(digestAlgorithm))
            .digest(datos);

    // MessageDigest
    contexExpecific.add(new Attribute(CMSAttributes.messageDigest, new DERSet(new DEROctetString(md.clone()))));

    // Serial Number
    // comentar lo de abajo para version del rfc 3852
    contexExpecific.add(new Attribute(RFC4519Style.serialNumber,
            new DERSet(new DERPrintableString(cert.getSerialNumber().toString()))));

    // agregamos la lista de atributos a mayores.
    if (atrib.size() != 0) {

        final Iterator<Map.Entry<String, byte[]>> it = atrib.entrySet().iterator();
        while (it.hasNext()) {
            final Map.Entry<String, byte[]> e = it.next();
            contexExpecific.add(new Attribute(
                    // el oid
                    new ASN1ObjectIdentifier(e.getKey().toString()),
                    // el array de bytes en formato string
                    new DERSet(new DERPrintableString(new String(e.getValue())))));
        }

    }

    return SigUtils.getAttributeSet(new AttributeTable(contexExpecific));
}

From source file:es.gob.afirma.envelopers.cms.CMSAuthenticatedEnvelopedData.java

License:Open Source License

/** Genera una estructura PKCS#7 <code>AuthenticatedEnvelopedData</code>.
 * @param parameters Par&aacute;metros necesarios que contienen tanto la firma del
 *                   archivo a firmar como los datos del firmante.
 * @param signerCertificateChain Cadena de certificados del firmante.
 * @param autenticationAlgorithm Algoritmo de autenticacion
 * @param config Configuraci&oacute;n del algoritmo para firmar
 * @param certDest Certificado del destino al cual va dirigido la firma.
 * @param dataType Identifica el tipo del contenido a firmar.
 * @param applySigningTime Si se aplica la hora de firma o no.
 * @param atrib Atributos firmados opcionales.
 * @param uatrib Atributos no autenticados firmados opcionales.
 * @param keySize Tama&ntilde;o de la clave AES.
 * @return Firma de tipo AuthenticatedData.
 * @throws IOException Si ocurre alg&uacute;n problema leyendo o escribiendo los
 *                     datos/*  ww  w.j a  v  a  2 s. c  o  m*/
 * @throws CertificateEncodingException Si se produce alguna excepci&oacute;n con los certificados de
 *                                      firma.
 * @throws NoSuchAlgorithmException Si no se encuentra un algoritmo v&aacute;lido.
 * @throws InvalidKeyException Cuando hay problemas de adecuaci&oacute;n de la clave.
 * @throws BadPaddingException Cuando hay problemas con un relleno de datos.
 * @throws IllegalBlockSizeException Cuando hay problemas internos con los tama&ntilde;os de bloque de cifrado.
 * @throws InvalidAlgorithmParameterException Si no se soporta un par&aacute;metro necesario para un algoritmo.
 * @throws NoSuchPaddingException Cuando no se soporta un tipo de relleno necesario. */
static byte[] genAuthenticatedEnvelopedData(final P7ContentSignerParameters parameters,
        final X509Certificate[] signerCertificateChain, final String autenticationAlgorithm,
        final AOCipherConfig config, final X509Certificate[] certDest, final String dataType,
        final boolean applySigningTime, final Map<String, byte[]> atrib, final Map<String, byte[]> uatrib,
        final Integer keySize) throws IOException, CertificateEncodingException, NoSuchAlgorithmException,
        InvalidKeyException, NoSuchPaddingException, InvalidAlgorithmParameterException,
        IllegalBlockSizeException, BadPaddingException {
    final SecretKey cipherKey = Utils.initEnvelopedData(config, keySize);

    // Ya que el contenido puede ser grande, lo recuperamos solo una vez
    final byte[] content2 = parameters.getContent();

    // 1. ORIGINATORINFO
    // obtenemos la lista de certificados
    final ASN1Set certificates = Utils.fetchCertificatesList(signerCertificateChain);
    ASN1Set certrevlist = null;

    OriginatorInfo origInfo = null;
    if (signerCertificateChain.length != 0) {
        // introducimos una lista vacia en los CRL ya que no podemos
        // modificar el codigo de bc.
        certrevlist = SigUtils.createBerSetFromList(new ArrayList<ASN1Encodable>());
        origInfo = new OriginatorInfo(certificates, certrevlist);
    }

    // 2. RECIPIENTINFOS
    final Info infos = Utils.initVariables(content2, config, certDest, cipherKey);

    // 4. ATRIBUTOS FIRMADOS
    final ASN1Set authAttr = generateSignedAtt(dataType, applySigningTime, atrib);

    // 5. MAC
    final byte[] mac = Utils.genMac(autenticationAlgorithm,
            genPack(authAttr.getEncoded(ASN1Encoding.DER), content2), cipherKey);

    // 6. ATRIBUTOS NO FIRMADOS.
    final ASN1Set unAuthAttr = Utils.generateUnsignedAtt(uatrib);

    // construimos el Authenticated data y lo devolvemos
    return new ContentInfo(PKCSObjectIdentifiers.id_ct_authEnvelopedData, new AuthEnvelopedData(origInfo, // originatorInfo,
            new DERSet(infos.getRecipientInfos()), // recipientInfos,
            infos.getEncInfo(), // authEncryptedContentInfo,
            authAttr, // authAttrs
            new DEROctetString(mac), // MAC
            unAuthAttr // unauthAttrs
    )).getEncoded(ASN1Encoding.DER);

}

From source file:es.gob.afirma.envelopers.cms.CMSData.java

License:Open Source License

/** M&eacute;odo que genera una estructura CMS de tipo Data.
 * @param content//w  w w  . java2s .  c om
 *        Datos que se desean envolver.
 * @return El envoltorio de tipo data.
 * @throws IOException En caso de error en la lectura o tratamiento de datos */
static byte[] genData(final byte[] content) throws IOException {
    return new ContentInfo(PKCSObjectIdentifiers.data, new DEROctetString(content))
            .getEncoded(ASN1Encoding.DER);
}

From source file:es.gob.afirma.envelopers.cms.CMSDigestedData.java

License:Open Source License

/** Genera una estructura de tipo digestedData.
 * @param content//w  w w .ja v  a2s . c  om
 *        Contenido original
 * @param digestAlgorithm
 *        Algoritmo de huella digital (<i>digest</i>) a usar
 * @param dataType
 *        Identifica el tipo del contenido a firmar.
 * @return Mensaje firmado en tipo Digested Data.
 * @throws java.security.NoSuchAlgorithmException
 *         Si no se soporta alguno de los algoritmos de firma o huella
 *         digital
 * @throws java.io.IOException
 *         Si ocurre alg&uacute;n problema leyendo o escribiendo los
 *         datos */
static byte[] genDigestedData(final byte[] content, final String digestAlgorithm, final String dataType)
        throws NoSuchAlgorithmException, IOException {

    // Obtenemos el algoritmo para hacer el digest
    final AlgorithmIdentifier digAlgId = SigUtils
            .makeAlgId(AOAlgorithmID.getOID(AOSignConstants.getDigestAlgorithmName(digestAlgorithm)));

    // indicamos el tipo de contenido
    final ASN1ObjectIdentifier contentTypeOID = new ASN1ObjectIdentifier(dataType);
    final ContentInfo encInfo = new ContentInfo(contentTypeOID, null);

    // digest
    final DEROctetString digest = new DEROctetString(
            MessageDigest.getInstance(digestAlgorithm).digest(content));

    // construimos el digestedData.
    return new ContentInfo(PKCSObjectIdentifiers.digestedData, new DigestedData(digAlgId, encInfo, digest))
            .getEncoded(ASN1Encoding.DER);
}

From source file:es.gob.afirma.envelopers.cms.CoSignerEnveloped.java

License:Open Source License

/** M&eacute;todo que genera la parte que contiene la informaci&oacute;n del
 * Usuario. Se generan los atributos que se necesitan para generar la firma.
 * @param digestAlgorithm//from  w  w  w .  ja  v  a  2 s .c  om
 *        Algoritmo Firmado.
 * @param datos
 *        Datos firmados.
 * @param dataType
 *        Identifica el tipo del contenido a firmar.
 * @param atrib
 *        Lista de atributos firmados que se insertar&aacute;n dentro
 *        del archivo de firma.
 * @return Los atributos firmados de la firma.
 * @throws java.security.NoSuchAlgorithmException Si el JRE no soporta alg&uacute;n algoritmo necesario */
private ASN1Set generateSignerInfo(final String digestAlgorithm, final byte[] datos, final String dataType,
        final Map<String, byte[]> atrib) throws NoSuchAlgorithmException {

    // // ATRIBUTOS

    // authenticatedAttributes
    final ASN1EncodableVector contexExpecific = new ASN1EncodableVector();

    // tipo de contenido
    contexExpecific
            .add(new Attribute(CMSAttributes.contentType, new DERSet(new ASN1ObjectIdentifier(dataType))));

    // fecha de firma
    contexExpecific.add(new Attribute(CMSAttributes.signingTime, new DERSet(new DERUTCTime(new Date()))));

    // Si nos viene el hash de fuera no lo calculamos
    final byte[] md = MessageDigest.getInstance(AOSignConstants.getDigestAlgorithmName(digestAlgorithm))
            .digest(datos);

    // MessageDigest
    contexExpecific.add(new Attribute(CMSAttributes.messageDigest, new DERSet(new DEROctetString(md.clone()))));

    // agregamos la lista de atributos a mayores.
    if (atrib.size() != 0) {
        final Iterator<Map.Entry<String, byte[]>> it = atrib.entrySet().iterator();
        while (it.hasNext()) {
            final Map.Entry<String, byte[]> e = it.next();
            contexExpecific.add(new Attribute(
                    // el oid
                    new ASN1ObjectIdentifier(e.getKey().toString()),
                    // el array de bytes en formato string
                    new DERSet(new DERPrintableString(new String(e.getValue())))));
        }
    }

    this.signedAttr2 = SigUtils.getAttributeSet(new AttributeTable(contexExpecific));

    return SigUtils.getAttributeSet(new AttributeTable(contexExpecific));

}

From source file:es.gob.afirma.envelopers.cms.CoSignerEnveloped.java

License:Open Source License

/** M&eacute;todo que genera la parte que contiene la informaci&oacute;n del
 * Usuario. Se generan los atributos que se necesitan para generar la firma.
 * En este caso se introduce el hash directamente.
 * @param cert Certificado necesario para la firma.
 * @param datos Datos firmados.//  ww w.j  av  a 2  s  .c  o  m
 * @param dataType Identifica el tipo del contenido a firmar.
 * @param atrib Lista de atributos firmados que se insertar&aacute;n dentro
 *              del archivo de firma.
 * @return Los atributos firmados de la firma. */
private ASN1Set generateSignerInfoFromHash(final X509Certificate cert, final byte[] datos,
        final String dataType, final Map<String, byte[]> atrib) {

    // // ATRIBUTOS

    // authenticatedAttributes
    final ASN1EncodableVector contexExpecific = new ASN1EncodableVector();

    // tipo de contenido
    contexExpecific
            .add(new Attribute(CMSAttributes.contentType, new DERSet(new ASN1ObjectIdentifier(dataType))));

    // fecha de firma
    contexExpecific.add(new Attribute(CMSAttributes.signingTime, new DERSet(new DERUTCTime(new Date()))));

    // MessageDigest
    contexExpecific.add(new Attribute(CMSAttributes.messageDigest, new DERSet(new DEROctetString(datos))));

    // Serial Number
    contexExpecific.add(new Attribute(RFC4519Style.serialNumber,
            new DERSet(new DERPrintableString(cert.getSerialNumber().toString()))));

    // agregamos la lista de atributos a mayores.
    if (atrib.size() != 0) {
        final Iterator<Map.Entry<String, byte[]>> it = atrib.entrySet().iterator();
        while (it.hasNext()) {
            final Map.Entry<String, byte[]> e = it.next();
            contexExpecific.add(new Attribute(
                    // el oid
                    new ASN1ObjectIdentifier(e.getKey().toString()),
                    // el array de bytes en formato string
                    new DERSet(new DERPrintableString(new String(e.getValue())))));
        }
    }

    this.signedAttr2 = SigUtils.getAttributeSet(new AttributeTable(contexExpecific));

    return SigUtils.getAttributeSet(new AttributeTable(contexExpecific));

}

From source file:es.gob.afirma.envelopers.cms.CoSignerEnveloped.java

License:Open Source License

/** Realiza la firma usando los atributos del firmante.
 * @param signatureAlgorithm Algoritmo para la firma.
 * @param keyEntry Clave para firmar./* w ww. j  a v  a  2  s .  co m*/
 * @return Firma de los atributos.
 * @throws InvalidKeyException Cuando hay problemas de adecuaci&oacute;n de la clave.
 * @throws NoSuchAlgorithmException Si el JRE no soporta alg&uacute;n algoritmo necesario
 * @throws IOException Cuando hay problemas de entrada / salida.
 * @throws SignatureException  Cuando ocurren problemas en la firma PKCS#1 */
private ASN1OctetString firma(final String signatureAlgorithm, final PrivateKeyEntry keyEntry)
        throws InvalidKeyException, NoSuchAlgorithmException, IOException, SignatureException {

    final Signature sig = Signature.getInstance(signatureAlgorithm);

    final byte[] tmp = this.signedAttr2.getEncoded(ASN1Encoding.DER);

    // Indicar clave privada para la firma
    sig.initSign(keyEntry.getPrivateKey());

    // Actualizamos la configuracion de firma
    sig.update(tmp);

    // firmamos y devolvemos.
    return new DEROctetString(sig.sign());

}

From source file:es.gob.afirma.envelopers.cms.CounterSignerEnveloped.java

License:Open Source License

/** M&eacute;todo que genera la parte que contiene la informaci&oacute;n del
 * Usuario. Se generan los atributos que se necesitan para generar la
 * firma.//w w  w  .ja  v  a  2 s .c  o  m
 * @param cert
 *        Certificado necesario para la firma.
 * @param digestAlgorithm
 *        Algoritmo Firmado.
 * @param datos
 *        Datos firmados.
 * @return Los datos necesarios para generar la firma referente a los datos
 *         del usuario.
 * @throws java.security.NoSuchAlgorithmException Cuando el JRE no soporta alg&uacute;n algoritmo necesario. */
private ASN1Set generateSignerInfo(final X509Certificate cert, final String digestAlgorithm, final byte[] datos)
        throws NoSuchAlgorithmException {

    // // ATRIBUTOS

    // authenticatedAttributes
    final ASN1EncodableVector contexExpecific = new ASN1EncodableVector();

    // Fecha de firma
    contexExpecific.add(new Attribute(CMSAttributes.signingTime, new DERSet(new DERUTCTime(new Date()))));

    // MessageDigest
    contexExpecific.add(new Attribute(CMSAttributes.messageDigest, new DERSet(new DEROctetString(MessageDigest
            .getInstance(AOSignConstants.getDigestAlgorithmName(digestAlgorithm)).digest(datos)))));

    // Serial Number
    contexExpecific.add(new Attribute(RFC4519Style.serialNumber,
            new DERSet(new DERPrintableString(cert.getSerialNumber().toString()))));

    // agregamos la lista de atributos a mayores.
    if (this.atrib2.size() != 0) {
        final Iterator<Map.Entry<String, byte[]>> it = this.atrib2.entrySet().iterator();
        while (it.hasNext()) {
            final Map.Entry<String, byte[]> e = it.next();
            contexExpecific.add(new Attribute(
                    // el oid
                    new ASN1ObjectIdentifier(e.getKey().toString()),
                    // el array de bytes en formato string
                    new DERSet(new DERPrintableString(new String(e.getValue())))));
        }
    }

    this.signedAttr2 = SigUtils.getAttributeSet(new AttributeTable(contexExpecific));

    return SigUtils.getAttributeSet(new AttributeTable(contexExpecific));

}