Browse Source

[Authentication] Fixed password hash constants

develop
Robin Thoni 9 years ago
parent
commit
92ef49594c
1 changed files with 7 additions and 4 deletions
  1. 7
    4
      Authentication/Business/JWT/PasswordHash.cs

+ 7
- 4
Authentication/Business/JWT/PasswordHash.cs View File

12
         private const int SALT_INDEX = 1;
12
         private const int SALT_INDEX = 1;
13
         private const int PBKDF2_INDEX = 2;
13
         private const int PBKDF2_INDEX = 2;
14
 
14
 
15
+        private const int SALT_BYTE_SIZE = 24;
16
+        private const int HASH_BYTE_SIZE = 42;
17
+        private const int PBKDF2_ITERATIONS = 2048;
18
+
15
         /// <summary>
19
         /// <summary>
16
         /// Crée un hash à partir du password
20
         /// Crée un hash à partir du password
17
         /// </summary>
21
         /// </summary>
21
         {
25
         {
22
             // génaration du SALT aléatoire
26
             // génaration du SALT aléatoire
23
             RNGCryptoServiceProvider csprng = new RNGCryptoServiceProvider();
27
             RNGCryptoServiceProvider csprng = new RNGCryptoServiceProvider();
24
-            byte[] salt = new byte[1024];
28
+            byte[] salt = new byte[SALT_BYTE_SIZE];
25
             csprng.GetBytes(salt);
29
             csprng.GetBytes(salt);
26
 
30
 
27
             // hash le password et création de la chaine avec les paramêtres
31
             // hash le password et création de la chaine avec les paramêtres
28
-            byte[] hash = PBKDF2(password, salt, 42, 1024);
29
-            return 42 + ":" +
32
+            byte[] hash = PBKDF2(password, salt, PBKDF2_ITERATIONS, HASH_BYTE_SIZE);
33
+            return PBKDF2_ITERATIONS + ":" +
30
                 Convert.ToBase64String(salt) + ":" + Convert.ToBase64String(hash);
34
                 Convert.ToBase64String(salt) + ":" + Convert.ToBase64String(hash);
31
-            return "";
32
         }
35
         }
33
 
36
 
34
         /// <summary>
37
         /// <summary>

Loading…
Cancel
Save