예제 #1
0
 /// <summary>
 /// Gets the crypto version.
 /// </summary>
 /// <returns>The crypto version.</returns>
 /// <param name="Date">Date.</param>
 public static string GetCryptoVersion(byte[] Date)
 {
     using (MemoryStream ms = new MemoryStream()) {
         BinaryFormatter bf = new BinaryFormatter();
         ms.Write(Date, 0, Date.Length);
         ms.Position = 0;
         PasswdBase tmp = bf.Deserialize(ms) as PasswdBase;
         if (tmp == null)
         {
             return(null);
         }
         return(tmp.VersionHash);
     }
 }
예제 #2
0
 /// <summary>
 /// Check the specified Date.
 /// the date is from disk or datebase
 /// </summary>
 /// <param name="Date">Date.</param>
 public bool Check(byte[] Date)
 {
     using (MemoryStream ms = new MemoryStream()) {
         BinaryFormatter bf = new BinaryFormatter();
         ms.Write(Date, 0, Date.Length);
         ms.Position = 0;
         PasswdBase tmp = bf.Deserialize(ms) as PasswdBase;
         if (tmp == null)
         {
             return(false);
         }
         //show this password is not in this check
         if (tmp.VersionHash != this.GetGUID())
         {
             return(false);
         }
         return(this.CheckSecret(tmp));
     }
 }
예제 #3
0
        protected override bool CheckSecret(PasswdBase info)
        {
            CryExtInfo infos = info.ExtraInfo as CryExtInfo;

            if (infos == null)
            {
                return(false);
            }
            using (HMACSHA512 hash512 = new HMACSHA512(infos.Key)) {
                byte[] pwdDate     = Encoding.UTF8.GetBytes(this.Password);
                byte[] pwdWithSalt = new byte[pwdDate.Length + infos.Salt.Length];
                Array.Copy(pwdDate, pwdWithSalt, pwdDate.Length);
                Array.Copy(infos.Salt, 0, pwdWithSalt, pwdDate.Length, infos.Salt.Length);
                byte[] pwdBuffer = hash512.ComputeHash(pwdWithSalt);
                for (int i = 0; i <= infos.Count; i++)
                {
                    pwdBuffer = hash512.ComputeHash(pwdBuffer);
                }
                return(this.SlowCompose(info.Password, pwdBuffer));
            }
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AbPasswdPlugin.Crypt"/> class.
 /// </summary>
 /// <param name="passwd">Passwd.</param>
 public PBKDF2(string passwd)
     : base(passwd)
 {
     this.date = new PasswdBase();
 }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AbPasswdPlugin.Crypt"/> class.
 /// </summary>
 public PBKDF2()
     : base("", 100, 200)
 {
     this.date = new PasswdBase();
 }
예제 #6
0
 /// <summary>
 /// Checks the secret.
 /// </summary>
 /// <returns><c>true</c>, if secret was checked, <c>false</c> otherwise.</returns>
 /// <param name="info">Info.</param>
 protected abstract bool CheckSecret(PasswdBase info);
예제 #7
0
파일: PBKDF2.cs 프로젝트: shby0527/Mohachi
 /// <summary>
 /// Initializes a new instance of the <see cref="AbPasswdPlugin.Crypt"/> class.
 /// </summary>
 public PBKDF2()
     : base("",100,200)
 {
     this.date = new PasswdBase ();
 }
예제 #8
0
파일: PBKDF2.cs 프로젝트: shby0527/Mohachi
 protected override bool CheckSecret(PasswdBase info)
 {
     CryExtInfo infos = info.ExtraInfo as CryExtInfo;
     if (infos == null)
         return false;
     using (HMACSHA512 hash512 = new HMACSHA512(infos.Key)) {
         byte[] pwdDate = Encoding.UTF8.GetBytes (this.Password);
         byte[] pwdWithSalt = new byte[pwdDate.Length + infos.Salt.Length];
         Array.Copy (pwdDate, pwdWithSalt, pwdDate.Length);
         Array.Copy (infos.Salt, 0, pwdWithSalt, pwdDate.Length, infos.Salt.Length);
         byte[] pwdBuffer = hash512.ComputeHash (pwdWithSalt);
         for (int i =0; i<=infos.Count; i++) {
             pwdBuffer = hash512.ComputeHash (pwdBuffer);
         }
         return this.SlowCompose (info.Password, pwdBuffer);
     }
 }
예제 #9
0
파일: PBKDF2.cs 프로젝트: shby0527/Mohachi
 /// <summary>
 /// Initializes a new instance of the <see cref="AbPasswdPlugin.Crypt"/> class.
 /// </summary>
 /// <param name="passwd">Passwd.</param>
 public PBKDF2(string passwd)
     : base(passwd)
 {
     this.date = new PasswdBase ();
 }
예제 #10
0
 /// <summary>
 /// Checks the secret.
 /// </summary>
 /// <returns><c>true</c>, if secret was checked, <c>false</c> otherwise.</returns>
 /// <param name="info">Info.</param>
 protected abstract bool CheckSecret(PasswdBase info);