CertRequest myCertRequest = new CertRequest(new DERInteger(4), myCertTemplate);
// myCertRequest.addControls(new
// AttributeTypeAndValue(CRMFObjectIdentifiers.regInfo_utf8Pairs, new
// DERInteger(12345)));
CertReqMsg myCertReqMsg = new CertReqMsg(myCertRequest);
// POPO
/*
* PKMACValue myPKMACValue = new PKMACValue( new AlgorithmIdentifier(new
* DERObjectIdentifier("8.2.1.2.3.4"), new DERBitString(new byte[] { 8,
* 1, 1, 2 })), new DERBitString(new byte[] { 12, 29, 37, 43 }));
*
* POPOPrivKey myPOPOPrivKey = new POPOPrivKey(new DERBitString(new
* byte[] { 44 }), 2); //take choice pos tag 2
*
* POPOSigningKeyInput myPOPOSigningKeyInput = new POPOSigningKeyInput(
* myPKMACValue, new SubjectPublicKeyInfo( new AlgorithmIdentifier(new
* DERObjectIdentifier("9.3.3.9.2.2"), new DERBitString(new byte[] { 2,
* 9, 7, 3 })), new byte[] { 7, 7, 7, 4, 5, 6, 7, 7, 7 }));
*/
ProofOfPossession myProofOfPossession = null;
if (raVerifiedPopo) {
// raVerified POPO (meaning there is no POPO)
myProofOfPossession = new ProofOfPossession(new DERNull(), 0);
} else {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DEROutputStream mout = new DEROutputStream(baos);
mout.writeObject(myCertRequest);
mout.close();
byte[] popoProtectionBytes = baos.toByteArray();
Signature sig = Signature.getInstance(PKCSObjectIdentifiers.sha1WithRSAEncryption.getId(), "BC");
sig.initSign(keys.getPrivate());
sig.update(popoProtectionBytes);
DERBitString bs = new DERBitString(sig.sign());
POPOSigningKey myPOPOSigningKey = new POPOSigningKey(new AlgorithmIdentifier(PKCSObjectIdentifiers.sha1WithRSAEncryption), bs);
// myPOPOSigningKey.setPoposkInput( myPOPOSigningKeyInput );
myProofOfPossession = new ProofOfPossession(myPOPOSigningKey, 1);
}
myCertReqMsg.setPop(myProofOfPossession);
// myCertReqMsg.addRegInfo(new AttributeTypeAndValue(new
// DERObjectIdentifier("1.3.6.2.2.2.2.3.1"), new
// DERInteger(1122334455)));
AttributeTypeAndValue av = new AttributeTypeAndValue(CRMFObjectIdentifiers.regCtrl_regToken, new DERUTF8String("foo123"));
myCertReqMsg.addRegInfo(av);
CertReqMessages myCertReqMessages = new CertReqMessages(myCertReqMsg);
// myCertReqMessages.addCertReqMsg(myCertReqMsg);
// log.debug("CAcert subject name: "+cacert.getSubjectDN().getName());