/// <summary> /// Constructor that accepts values for all mandatory fields /// </summary> ///<param name="algorithm">The method used to encrypt the user's password. See the implementation details below.</param> ///<param name="keyName">The name of the key to be used for decryption of the password. Left blank for plain, encoded text (Algorithm attribute value of "base64") and hash algorithms.</param> ///<param name="value">Gets or sets the content value of the &lt;Password&gt; element</param> /// public Password( PasswordAlgorithm algorithm, string keyName, string value ) : base(InfraDTD.PASSWORD) { this.SetAlgorithm( algorithm ); this.KeyName = keyName; this.Value = value; }
/// <summary> /// Sets the value of the <c>Algorithm</c> attribute. /// </summary> /// <param name="val">A PasswordAlgorithm object</param> /// <remarks> /// <para>The SIF specification defines the meaning of this attribute as: "The method used to encrypt the user's password. See the implementation details below."</para> /// <para>Version: 2.5</para> /// <para>Since: 1.5r1</para> /// </remarks> public void SetAlgorithm( PasswordAlgorithm val ) { SetField( InfraDTD.PASSWORD_ALGORITHM, val ); }
/// <summary> /// Sets the value of the <c>Algorithm</c> attribute. /// </summary> /// <param name="val">A PasswordAlgorithm object</param> /// <remarks> /// <para>The SIF specification defines the meaning of this attribute as: "The method used to encrypt the user's password. See the implementation details below."</para> /// <para>Version: 2.6</para> /// <para>Since: 1.5r1</para> /// </remarks> public void SetAlgorithm(PasswordAlgorithm val) { SetField(InfraDTD.PASSWORD_ALGORITHM, val); }
/// <summary> /// Constructor that accepts values for all mandatory fields /// </summary> ///<param name="algorithm">The method used to encrypt the user's password. See the implementation details below.</param> ///<param name="keyName">The name of the key to be used for decryption of the password. Left blank for plain, encoded text (Algorithm attribute value of "base64") and hash algorithms.</param> ///<param name="value">Gets or sets the content value of the &lt;Password&gt; element</param> /// public Password(PasswordAlgorithm algorithm, string keyName, string value) : base(InfraDTD.PASSWORD) { this.SetAlgorithm(algorithm); this.KeyName = keyName; this.Value = value; }
public SifSymmetricEncryption( PasswordAlgorithm algorithm, string keyName, SymmetricAlgorithm alg, byte [] key ) : base(algorithm, keyName) { fSymmetricAlgorithm = alg; alg.Key = key; alg.BlockSize = 64; alg.Mode = CipherMode.CBC; alg.Padding = PaddingMode.PKCS7; }
public SifHashEncryption( PasswordAlgorithm algorithm, string keyName, HashAlgorithm alg ) : base(algorithm, string.Empty) { fHashAlgorithm = alg; }
public SifClearTextEncryption( PasswordAlgorithm algorithm, string keyName ) : base(algorithm, string.Empty) { }
/// <summary> /// Creates an instance of SIFEncryption that uses the specified /// PasswordAlgorithm, keyName and key /// </summary> /// <param name="algorithm">The algorithm to use for encrypting or decrypting passwords</param> /// <param name="keyName">The name of the encryption key to use.</param> /// <param name="key">The encryption key to use. This parameter is ignored for /// SHA1 and MD5 because they are not keyed hash algorithms </param> /// <returns>An instance of the SifEncryption class for reading and writing passwords</returns> public static SifEncryption GetInstance( PasswordAlgorithm algorithm, string keyName, byte [] key ) { if ( sCurrentInstance != null ) { if ( !sCurrentInstance.fDisposed && sCurrentInstance.Algorithm.Value.Equals( algorithm.Value ) && (sCurrentInstance.KeyName == keyName || sCurrentInstance.Key == null) ) { return sCurrentInstance; } else { sCurrentInstance.Dispose(); sCurrentInstance = null; } } if (algorithm.ValueEquals("base64")){ sCurrentInstance = new SifClearTextEncryption( algorithm, keyName ); } else if ( algorithm.Value == PasswordAlgorithm.SHA1.Value ) { sCurrentInstance = new SifHashEncryption( algorithm, keyName, new SHA1Managed() ); } else if ( algorithm.Value == PasswordAlgorithm.MD5.Value ) { sCurrentInstance = new SifHashEncryption( algorithm, keyName, new MD5CryptoServiceProvider() ); } else if ( algorithm.Value == PasswordAlgorithm.DES.Value ) { sCurrentInstance = new SifSymmetricEncryption ( algorithm, keyName, new DESCryptoServiceProvider(), key ); } else if ( algorithm.Value == PasswordAlgorithm.TRIPLEDES.Value ) { sCurrentInstance = new SifSymmetricEncryption ( algorithm, keyName, new TripleDESCryptoServiceProvider(), key ); } else if ( algorithm.Value == PasswordAlgorithm.RC2.Value ) { sCurrentInstance = new SifSymmetricEncryption ( algorithm, keyName, new RC2CryptoServiceProvider(), key ); } else { throw new AdkNotSupportedException ( string.Format( "Encryption algorithm {0} is not supported.", algorithm.Value ) ); } return sCurrentInstance; }
private SifEncryption( PasswordAlgorithm algorithm, string keyName ) { fkeyName = keyName; fAlgorithm = algorithm; }