private byte[] CreateIV(DekAlgorithm algorithm) { if (algorithm.Name.EndsWith("ECB")) { return(null); } byte[] iv; if (algorithm.Name.Contains("AES")) { iv = new byte[16]; } else { iv = new byte[8]; } if (random != null) { random.NextBytes(iv); } else { CryptoServicesRegistrar.GetSecureRandom().NextBytes(iv); } return(iv); }
/// <summary> /// Base constructor. /// </summary> /// <param name="algorithm">The basic DEK-Info describing the cipher.</param> public OpenSslPemEncryptorBuilder(DekAlgorithm algorithm) { this.algorithm = algorithm; }