gen1.addSigner(keys.getPrivate(), cert, CMSSignedDataGenerator.DIGEST_SHA1,
gen1.addSigner(keys.getPrivate(), cert, digestOid,
    private CMSSignedData sign(CMSProcessable signThis, String messageType) throws NoSuchAlgorithmException, NoSuchProviderException, CMSException, IOException, InvalidAlgorithmParameterException, CertStoreException {        CMSSignedDataGenerator gen1 = new CMSSignedDataGenerator();        // add authenticated attributes...status, transactionId, sender- and more...        Hashtable attributes = new Hashtable();        DERObjectIdentifier oid;        Attribute attr;        DERSet value;                // Message type (certreq)        oid = new DERObjectIdentifier(ScepRequestMessage.id_messageType);        value = new DERSet(new DERPrintableString(messageType));        attr = new Attribute(oid, value);        attributes.put(attr.getAttrType(), attr);        // TransactionId        byte[] digest = CertTools.generateMD5Fingerprint(cert.getPublicKey().getEncoded());        transactionId = new String(Base64.encode(digest));        oid = new DERObjectIdentifier(ScepRequestMessage.id_transId);        value = new DERSet(new DERPrintableString(Base64.encode(digest)));        attr = new Attribute(oid, value);        attributes.put(attr.getAttrType(), attr);        // senderNonce        byte[] nonce = new byte[16];        SecureRandom randomSource = SecureRandom.getInstance("SHA1PRNG");        randomSource.nextBytes(nonce);        senderNonce = new String(Base64.encode(nonce));        if (nonce != null) {            oid = new DERObjectIdentifier(ScepRequestMessage.id_senderNonce);            log.debug("Added senderNonce: " + senderNonce);            value = new DERSet(new DEROctetString(nonce));            attr = new Attribute(oid, value);            attributes.put(attr.getAttrType(), attr);        }        // Add our signer info and sign the message        ArrayList certList = new ArrayList();        certList.add(cert);        CertStore certs = CertStore.getInstance("Collection", new CollectionCertStoreParameters(certList), "BC");        gen1.addCertificatesAndCRLs(certs);        gen1.addSigner(keys.getPrivate(), cert, CMSSignedDataGenerator.DIGEST_SHA1,                new AttributeTable(attributes), null);        // The signed data to be enveloped        CMSSignedData s = gen1.generate(signThis, true, "BC");        return s;    }