Beispiel #1
0
 /// <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();
     }
 }
Beispiel #2
0
        /// <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();
            }
        }
Beispiel #3
0
 /// <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);
 }
Beispiel #4
0
 /// <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);
 }
Beispiel #5
0
 /// <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);
 }