@@ -63,14 +63,15 @@ class MallocPtr {
6363const tCost = 3 ;
6464const mCost = 1024 ;
6565const 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:
6869// typedef enum Argon2_type {
6970// Argon2_d = 0,
7071// Argon2_i = 1,
7172// Argon2_id = 2
7273// } argon2_type;
73- const argon2Type = 2 ;
74+ const argon2idType = 2 ;
7475const version = 0x13 ;
7576const saltLength = 12 ;
7677
@@ -82,7 +83,7 @@ class Benchmark {
8283 }
8384
8485 for ( let i = 0 ; i < passwordStrings . length ; ++ i )
85- this . hashAndVerify ( passwordStrings [ i ] , argon2Type ) ;
86+ this . hashAndVerify ( passwordStrings [ i ] ) ;
8687 }
8788
8889 randomSalt ( ) {
@@ -93,17 +94,17 @@ class Benchmark {
9394 return result ;
9495 }
9596
96- hashAndVerify ( password , argon2Type ) {
97+ hashAndVerify ( password ) {
9798 password = new CString ( password ) ;
9899 let salt = this . randomSalt ( ) ;
99100 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 ) ;
101102
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 ) ;
103104 if ( status !== 0 )
104105 throw new Error ( `argon2_hash exited with status: ${ status } (${ Module . UTF8ToString ( Module . _argon2_error_message ( status ) ) } )` ) ;
105106
106- status = Module . _argon2_verify ( encodedBuffer . ptr , password . ptr , password . length , argon2Type ) ;
107+ status = Module . _argon2_verify ( encodedBuffer . ptr , password . ptr , password . length , argon2idType ) ;
107108 if ( status !== 0 )
108109 throw new Error ( `argon2_verify exited with status: ${ status } (${ Module . UTF8ToString ( Module . _argon2_error_message ( status ) ) } )` ) ;
109110
0 commit comments