@@ -63,14 +63,15 @@ class MallocPtr {
63
63
const tCost = 3 ;
64
64
const mCost = 1024 ;
65
65
const parallelism = 1 ;
66
- // There are three argon2 types (modes), we test all three. See wasm/argon2/include/argon2.h for the enum:
67
- // /* Argon2 primitive type */
66
+ // There are three argon2 types (modes), but they all exercise the same computational kernel,
67
+ // so we chose the recommended one from a security standpoint.
68
+ // See wasm/argon2/include/argon2.h for the enum:
68
69
// typedef enum Argon2_type {
69
70
// Argon2_d = 0,
70
71
// Argon2_i = 1,
71
72
// Argon2_id = 2
72
73
// } argon2_type;
73
- const argon2Type = 2 ;
74
+ const argon2idType = 2 ;
74
75
const version = 0x13 ;
75
76
const saltLength = 12 ;
76
77
@@ -82,7 +83,7 @@ class Benchmark {
82
83
}
83
84
84
85
for ( let i = 0 ; i < passwordStrings . length ; ++ i )
85
- this . hashAndVerify ( passwordStrings [ i ] , argon2Type ) ;
86
+ this . hashAndVerify ( passwordStrings [ i ] ) ;
86
87
}
87
88
88
89
randomSalt ( ) {
@@ -93,17 +94,17 @@ class Benchmark {
93
94
return result ;
94
95
}
95
96
96
- hashAndVerify ( password , argon2Type ) {
97
+ hashAndVerify ( password ) {
97
98
password = new CString ( password ) ;
98
99
let salt = this . randomSalt ( ) ;
99
100
let hashBuffer = new MallocPtr ( 24 ) ;
100
- let encodedBuffer = new MallocPtr ( Module . _argon2_encodedlen ( tCost , mCost , parallelism , salt . size , hashBuffer . size , argon2Type ) + 1 ) ;
101
+ let encodedBuffer = new MallocPtr ( Module . _argon2_encodedlen ( tCost , mCost , parallelism , salt . size , hashBuffer . size , argon2idType ) + 1 ) ;
101
102
102
- let status = Module . _argon2_hash ( tCost , mCost , parallelism , password . ptr , password . length , salt . ptr , salt . size , hashBuffer . ptr , hashBuffer . size , encodedBuffer . ptr , encodedBuffer . size , argon2Type , version ) ;
103
+ let status = Module . _argon2_hash ( tCost , mCost , parallelism , password . ptr , password . length , salt . ptr , salt . size , hashBuffer . ptr , hashBuffer . size , encodedBuffer . ptr , encodedBuffer . size , argon2idType , version ) ;
103
104
if ( status !== 0 )
104
105
throw new Error ( `argon2_hash exited with status: ${ status } (${ Module . UTF8ToString ( Module . _argon2_error_message ( status ) ) } )` ) ;
105
106
106
- status = Module . _argon2_verify ( encodedBuffer . ptr , password . ptr , password . length , argon2Type ) ;
107
+ status = Module . _argon2_verify ( encodedBuffer . ptr , password . ptr , password . length , argon2idType ) ;
107
108
if ( status !== 0 )
108
109
throw new Error ( `argon2_verify exited with status: ${ status } (${ Module . UTF8ToString ( Module . _argon2_error_message ( status ) ) } )` ) ;
109
110
0 commit comments