use of org.bouncycastle.asn1.pkcs.IssuerAndSerialNumber in project jruby-openssl by jruby.
the class SignerInfoWithPkey method set.
/* c: PKCS7_SIGNER_INFO_set
*
*/
public void set(X509AuxCertificate x509, PrivateKey pkey, MessageDigest dgst) throws PKCS7Exception {
boolean dsa = (pkey instanceof DSAPrivateKey) || (pkey instanceof ECPrivateKey);
version = new ASN1Integer(BigInteger.ONE);
X500Name issuer = X500Name.getInstance(x509.getIssuerX500Principal().getEncoded());
BigInteger serial = x509.getSerialNumber();
issuerAndSerialNumber = new IssuerAndSerialNumber(issuer, serial);
this.pkey = pkey;
if (dsa) {
digAlgorithm = new AlgorithmIdentifier(OID_sha1);
} else {
digAlgorithm = new AlgorithmIdentifier(ASN1Registry.nid2obj(EVP.type(dgst)));
}
if (pkey instanceof RSAPrivateKey) {
digEncryptionAlgorithm = new AlgorithmIdentifier(OID_rsaEncryption);
} else if (pkey instanceof DSAPrivateKey) {
digEncryptionAlgorithm = new AlgorithmIdentifier(OID_dsa);
} else if (pkey instanceof ECPrivateKey) {
digEncryptionAlgorithm = new AlgorithmIdentifier(OID_ecdsa_with_SHA1);
}
}
use of org.bouncycastle.asn1.pkcs.IssuerAndSerialNumber in project jruby-openssl by jruby.
the class SignerInfoWithPkey method toASN1Object.
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* SignerInfo ::= SEQUENCE {
* version Version,
* issuerAndSerialNumber IssuerAndSerialNumber,
* digestAlgorithm DigestAlgorithmIdentifier,
* authenticatedAttributes [0] IMPLICIT Attributes OPTIONAL,
* digestEncryptionAlgorithm DigestEncryptionAlgorithmIdentifier,
* encryptedDigest EncryptedDigest,
* unauthenticatedAttributes [1] IMPLICIT Attributes OPTIONAL
* }
*
* EncryptedDigest ::= OCTET STRING
*
* DigestAlgorithmIdentifier ::= AlgorithmIdentifier
*
* DigestEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
* </pre>
*/
public ASN1Encodable toASN1Object() {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(version);
v.add(issuerAndSerialNumber);
v.add(digAlgorithm);
if (authenticatedAttributes != null) {
v.add(new DERTaggedObject(false, 0, authenticatedAttributes));
}
v.add(digEncryptionAlgorithm);
v.add(encryptedDigest);
if (unauthenticatedAttributes != null) {
v.add(new DERTaggedObject(false, 1, unauthenticatedAttributes));
}
return new DLSequence(v);
}
Aggregations