/// <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); }
void SetDefault(ref CryptoAlgorithmID Current, CryptoAlgorithm New, CryptoAlgorithmID ID, CryptoAlgorithmClass Class) { if (Current == CryptoAlgorithmID.NULL & (New.AlgorithmClass == Class)) { Current = ID; } }