Pkcs10CertificationRequestDelaySigned
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.Pkcs;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.X509;
using System;
using System.IO;
namespace Org.BouncyCastle.Pkcs
{
public class Pkcs10CertificationRequestDelaySigned : Pkcs10CertificationRequest
{
protected Pkcs10CertificationRequestDelaySigned()
{
}
public Pkcs10CertificationRequestDelaySigned(byte[] encoded)
: base(encoded)
{
}
public Pkcs10CertificationRequestDelaySigned(Asn1Sequence seq)
: base(seq)
{
}
public Pkcs10CertificationRequestDelaySigned(Stream input)
: base(input)
{
}
public Pkcs10CertificationRequestDelaySigned(string signatureAlgorithm, X509Name subject, AsymmetricKeyParameter publicKey, Asn1Set attributes, AsymmetricKeyParameter signingKey)
: base(signatureAlgorithm, subject, publicKey, attributes, signingKey)
{
}
public Pkcs10CertificationRequestDelaySigned(string signatureAlgorithm, X509Name subject, SubjectPublicKeyInfo pubInfo, Asn1Set attributes, AsymmetricKeyParameter signingKey)
: base(signatureAlgorithm, subject, pubInfo, attributes, signingKey)
{
}
public Pkcs10CertificationRequestDelaySigned(string signatureAlgorithm, X509Name subject, AsymmetricKeyParameter publicKey, Asn1Set attributes)
: this(signatureAlgorithm, subject, GetPubInfo(publicKey), attributes)
{
}
public Pkcs10CertificationRequestDelaySigned(string signatureAlgorithm, X509Name subject, SubjectPublicKeyInfo pubInfo, Asn1Set attributes)
{
if (signatureAlgorithm == null)
throw new ArgumentNullException("signatureAlgorithm");
if (subject == null)
throw new ArgumentNullException("subject");
if (pubInfo == null)
throw new ArgumentNullException("pubInfo");
if (!Pkcs10CertificationRequest.m_algorithms.TryGetValue(signatureAlgorithm, out DerObjectIdentifier value) && !DerObjectIdentifier.TryFromID(signatureAlgorithm, out value))
throw new ArgumentException("Unknown signature type requested");
Asn1Encodable value2;
if (Pkcs10CertificationRequest.m_noParams.Contains(value))
sigAlgId = new AlgorithmIdentifier(value);
else if (Pkcs10CertificationRequest.m_exParams.TryGetValue(signatureAlgorithm, out value2)) {
sigAlgId = new AlgorithmIdentifier(value, value2);
} else {
sigAlgId = new AlgorithmIdentifier(value, DerNull.Instance);
}
reqInfo = new CertificationRequestInfo(subject, pubInfo, attributes);
}
public byte[] GetDataToSign()
{
return reqInfo.GetDerEncoded();
}
public void SignRequest(byte[] signedData)
{
sigBits = new DerBitString(signedData);
}
public void SignRequest(DerBitString signedData)
{
sigBits = signedData;
}
private static SubjectPublicKeyInfo GetPubInfo(AsymmetricKeyParameter publicKey)
{
if (publicKey == null)
throw new ArgumentNullException("publicKey");
if (publicKey.IsPrivate)
throw new ArgumentException("expected public key", "publicKey");
return SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(publicKey);
}
}
}