Base class for cryptography providers.
コード例 #1
0
 /// <summary>
 /// Construct from a subject key, subject name and issuer name.
 /// </summary>
 /// <param name="SubjectKey">Key that the certificate will authenticate.</param>
 /// <param name="SubjectName">Subject name.</param>
 public TBSCertificate(
         CryptoProvider SubjectKey,
          List<Name> SubjectName) : this () {
     
     SetValidity();
     Subject = SubjectName;
     var KeyPair = SubjectKey.KeyPair;
     SubjectPublicKeyInfo = KeyPair.KeyInfoData;
     }
コード例 #2
0
        /// <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);
            }
コード例 #3
0
 /// <summary>
 /// Create an instance from the public properties of the specified CryptoProvider.
 /// </summary>
 /// <param name="CryptoProvider">Template from which to take the properties.</param>
 public CryptoAlgorithm(CryptoProvider CryptoProvider) {
     this._Name = CryptoProvider.Name;
     this._OID = CryptoConfig.MapNameToOID(Name);
     this._GetCryptoProvider = CryptoProvider.GetCryptoProvider;
     this._KeySize = CryptoProvider.Size;
     _JSON_use = CryptoProvider.JSONKeyUse;
     _JSON_kty = CryptoProvider.JSONKeyType;
     _AlgorithmClass = CryptoProvider.AlgorithmClass;
     }
コード例 #4
0
        /// <summary>
        /// Add a cryptographic algorithm provider to the catalog
        /// </summary>
        /// <param name="CryptoProvider"></param>
        public void Add(CryptoProvider CryptoProvider) {
            var ID = CryptoProvider.CryptoAlgorithmID;
            var Slot = (int)ID;
            var CryptoAlgorithm = CryptoProvider.CryptoAlgorithm;
            if (CryptoAlgorithm == null) {
                CryptoAlgorithm = new CryptoAlgorithm(CryptoProvider);
                }

            // If the array isn't big enough, then grow it
            if (Slot >= Algorithms.Length) {
                Array.Resize(ref Algorithms, Slot + 1);
                }

            Algorithms[(int)Slot] = CryptoAlgorithm;

            SetDefault(ref _AlgorithmDigest, CryptoAlgorithm, ID, CryptoAlgorithmClass.Digest);
            SetDefault(ref _AlgorithmMAC, CryptoAlgorithm, ID, CryptoAlgorithmClass.MAC);
            SetDefault(ref _AlgorithmEncryption, CryptoAlgorithm, ID, CryptoAlgorithmClass.Encryption);
            SetDefault(ref _AlgorithmSignature, CryptoAlgorithm, ID, CryptoAlgorithmClass.Signature);
            SetDefault(ref _AlgorithmExchange, CryptoAlgorithm, ID, CryptoAlgorithmClass.Exchange);
            }
コード例 #5
0
 /// <summary>
 /// Create name from the UDF fingerprint of a key.
 /// </summary>
 /// <param name="CryptoProvider"></param>
 public Name(CryptoProvider CryptoProvider) :
         this (CryptoProvider.UDF) {
     }