Crypto provider for digital signature algorithms. The chief reason this is necessary is the excrable nature of the .NET APIs in which the base class does not expose methods such as sign.
Inheritance: CryptoProviderAsymmetric
 /// <summary>
 /// Sign the request
 /// </summary>
 /// <param name="SigningKey"></param>
 public void Sign(CryptoProviderSignature SigningKey) {
     SignatureAlgorithm = new AlgorithmIdentifier(SigningKey.OID);
     var SignatureData = SigningKey.Sign(CertificationRequestInfo.DER());
     Signature = SignatureData.Integrity;
     }
        /// <summary>
        /// Create a certificate with the specified subject Key. Note that the template is 
        /// must be completed with calls to set validity etc. before use.
        /// </summary>
        /// <param name="SubjectKey">Cryptographic provider for the subject key.</param>
        /// <param name="Application">Certificate application(s).</param>
        public Certificate(CryptoProvider SubjectKey, Application Application) {
            _KeyPair = SubjectKey.KeyPair;
            if (SubjectKey as CryptoProviderSignature != null) {
                _CryptoProviderSignature = SubjectKey as CryptoProviderSignature;
                }
            if (SubjectKey as CryptoProviderExchange != null) {
                _CryptoProviderExchange = SubjectKey as CryptoProviderExchange;
                }

            var SubjectName = new Name(SubjectKey).ToList();
            TBSCertificate = new TBSCertificate(SubjectKey.KeyPair, SubjectName);
            }
        /// <summary>
        /// Sign certificate.
        /// </summary>
        /// <param name="Signer">Cryptographic provider for the signer.</param>
        public void Sign(CryptoProviderSignature Signer) {

            TBSCertificate.Signature = new AlgorithmIdentifier(Signer.OID);
            SignatureAlgorithm = TBSCertificate.Signature;

            var Data = TBSCertificate.DER();
            var SignatureData = Signer.Sign(Data);
            Signature = SignatureData.Integrity;

            _Data = this.DER();
            }
Esempio n. 4
0
        /// <summary>
        /// Initialize the alg and kid parameters to match the specified 
        /// signature provider.
        /// </summary>
        /// <param name="SignatureProvider"></param>
        public SignatureHeader(CryptoProviderSignature SignatureProvider) {
            kid = SignatureProvider.UDF;
            alg = SignatureProvider.JSONName;

            }