/// <summary> /// Applies a security level to this object. /// </summary> /// <param name="securityLevel">The security level.</param> public void ApplySecurityLevel(SecurityLevel securityLevel) { switch (securityLevel) { case SecurityLevel.Minimum: this.SymmetricKeySize = 128; this.AsymmetricKeySize = 512; this.SymmetricHashAlgorithm = HashAlgorithm.Sha1; break; case SecurityLevel.Maximum: this.SymmetricKeySize = 256; this.AsymmetricKeySize = 4096; this.SymmetricHashAlgorithm = HashAlgorithm.Sha256; break; default: throw new ArgumentException(); } }
/// <summary> /// Initializes a new instance of the <see cref="CryptoSettings"/> class. /// </summary> /// <param name="securityLevel">The security level.</param> public CryptoSettings(SecurityLevel securityLevel = SecurityLevel.Maximum) { this.ApplySecurityLevel(securityLevel); }
/// <summary> /// Sets the specified security level's key lengths to the specified crypto provider. /// </summary> /// <param name="cryptoProvider">The crypto provider.</param> /// <param name="level">The level of security to apply.</param> public static void ApplySecurityLevel(this ICryptoProvider cryptoProvider, SecurityLevel level) { level.Apply(cryptoProvider); }