@@ -14,99 +14,194 @@ void main() {
1414 testWidgets ('v = ${0x13 }, t = 2, m = 16, p = 1,' , (tester) async {
1515 await Future .delayed (Duration (seconds: 1 ));
1616 await tester.pumpAndSettle ();
17- var code = await hashTest (Argon2Version .V13 , 2 , 16 , 1 , 'password' , 'somesalt' ,
17+ var code = await hashTest (
18+ Argon2Version .V13 ,
19+ 2 ,
20+ 16 ,
21+ 1 ,
22+ 'password' ,
23+ 'somesalt' ,
1824 '03df1d13e10203bcc663405e31ab1687939730c9152459bca28fd10c23e38f50' ,
19- '\$ argon2i\$ v=19\$ m=16,t=2,p=1\$ c29tZXNhbHQ\$ A98dE+ECA7zGY0BeMasWh5OXMMkVJFm8oo/RDCPjj1A' , Argon2Type .i);
25+ '\$ argon2i\$ v=19\$ m=16,t=2,p=1\$ c29tZXNhbHQ\$ A98dE+ECA7zGY0BeMasWh5OXMMkVJFm8oo/RDCPjj1A' ,
26+ Argon2Type .i);
2027 expect (code, DArgon2ErrorCode .ARGON2_OK );
2128 });
2229 testWidgets ('v = ${0x13 }, t = 2, m = 18, p = 1,' , (_) async {
23- var code = await hashTest (Argon2Version .V13 , 2 , 18 , 1 , 'password' , 'somesalt' ,
30+ var code = await hashTest (
31+ Argon2Version .V13 ,
32+ 2 ,
33+ 18 ,
34+ 1 ,
35+ 'password' ,
36+ 'somesalt' ,
2437 '3b1b4ad0a66b3f00b4cd04225e4e6da950ee152bf0d29aabcb123c2f1a90567a' ,
25- '\$ argon2i\$ v=19\$ m=18,t=2,p=1\$ c29tZXNhbHQ\$ OxtK0KZrPwC0zQQiXk5tqVDuFSvw0pqryxI8LxqQVno' , Argon2Type .i);
38+ '\$ argon2i\$ v=19\$ m=18,t=2,p=1\$ c29tZXNhbHQ\$ OxtK0KZrPwC0zQQiXk5tqVDuFSvw0pqryxI8LxqQVno' ,
39+ Argon2Type .i);
2640 expect (code, DArgon2ErrorCode .ARGON2_OK );
2741 });
2842 testWidgets ('v = ${0x13 }, t = 2, m = 8, p = 1,' , (_) async {
29- var code = await hashTest (Argon2Version .V13 , 2 , 8 , 1 , 'password' , 'somesalt' ,
43+ var code = await hashTest (
44+ Argon2Version .V13 ,
45+ 2 ,
46+ 8 ,
47+ 1 ,
48+ 'password' ,
49+ 'somesalt' ,
3050 '48cc13c16c5a2d254a278e2c44420ba0fb2d0f070661e35d6486604a7a2ff1a9' ,
31- '\$ argon2i\$ v=19\$ m=8,t=2,p=1\$ c29tZXNhbHQ\$ SMwTwWxaLSVKJ44sREILoPstDwcGYeNdZIZgSnov8ak' , Argon2Type .i);
51+ '\$ argon2i\$ v=19\$ m=8,t=2,p=1\$ c29tZXNhbHQ\$ SMwTwWxaLSVKJ44sREILoPstDwcGYeNdZIZgSnov8ak' ,
52+ Argon2Type .i);
3253 expect (code, DArgon2ErrorCode .ARGON2_OK );
3354 });
3455 testWidgets ('v = ${0x13 }, t = 2, m = 16, p = 2,' , (_) async {
35- var code = await hashTest (Argon2Version .V13 , 2 , 16 , 2 , 'password' , 'somesalt' ,
56+ var code = await hashTest (
57+ Argon2Version .V13 ,
58+ 2 ,
59+ 16 ,
60+ 2 ,
61+ 'password' ,
62+ 'somesalt' ,
3663 '7fbb85db7e9636115f2fd0f29ea4214baaada18b39fffed7875eeb9fa9b308c5' ,
37- '\$ argon2i\$ v=19\$ m=16,t=2,p=2\$ c29tZXNhbHQ\$ f7uF236WNhFfL9DynqQhS6qtoYs5//7Xh17rn6mzCMU' , Argon2Type .i);
64+ '\$ argon2i\$ v=19\$ m=16,t=2,p=2\$ c29tZXNhbHQ\$ f7uF236WNhFfL9DynqQhS6qtoYs5//7Xh17rn6mzCMU' ,
65+ Argon2Type .i);
3866 expect (code, DArgon2ErrorCode .ARGON2_OK );
3967 });
4068 });
4169 // Argon2d test group
4270 group ('Hash Tests - Argon2d' , () {
4371 testWidgets ('v = ${0x13 }, t = 2, m = 16, p = 1,' , (_) async {
44- var code = await hashTest (Argon2Version .V13 , 2 , 16 , 1 , 'password' , 'somesalt' ,
72+ var code = await hashTest (
73+ Argon2Version .V13 ,
74+ 2 ,
75+ 16 ,
76+ 1 ,
77+ 'password' ,
78+ 'somesalt' ,
4579 'e742c05880c44c4df5fe79937be77897a6e41ca758affc42301f1e4040e35bd2' ,
46- '\$ argon2d\$ v=19\$ m=16,t=2,p=1\$ c29tZXNhbHQ\$ 50LAWIDETE31/nmTe+d4l6bkHKdYr/xCMB8eQEDjW9I' , Argon2Type .d);
80+ '\$ argon2d\$ v=19\$ m=16,t=2,p=1\$ c29tZXNhbHQ\$ 50LAWIDETE31/nmTe+d4l6bkHKdYr/xCMB8eQEDjW9I' ,
81+ Argon2Type .d);
4782 expect (code, DArgon2ErrorCode .ARGON2_OK );
4883 });
4984 testWidgets ('v = ${0x13 }, t = 2, m = 18, p = 1,' , (_) async {
50- var code = await hashTest (Argon2Version .V13 , 2 , 18 , 1 , 'password' , 'somesalt' ,
85+ var code = await hashTest (
86+ Argon2Version .V13 ,
87+ 2 ,
88+ 18 ,
89+ 1 ,
90+ 'password' ,
91+ 'somesalt' ,
5192 'd24d7d614122db6458d66b4f35dc45b1cca59f9b71945db207e78062601d2dd5' ,
52- '\$ argon2d\$ v=19\$ m=18,t=2,p=1\$ c29tZXNhbHQ\$ 0k19YUEi22RY1mtPNdxFscyln5txlF2yB+eAYmAdLdU' , Argon2Type .d);
93+ '\$ argon2d\$ v=19\$ m=18,t=2,p=1\$ c29tZXNhbHQ\$ 0k19YUEi22RY1mtPNdxFscyln5txlF2yB+eAYmAdLdU' ,
94+ Argon2Type .d);
5395 expect (code, DArgon2ErrorCode .ARGON2_OK );
5496 });
5597 testWidgets ('v = ${0x13 }, t = 2, m = 8, p = 1,' , (_) async {
56- var code = await hashTest (Argon2Version .V13 , 2 , 8 , 1 , 'password' , 'somesalt' ,
98+ var code = await hashTest (
99+ Argon2Version .V13 ,
100+ 2 ,
101+ 8 ,
102+ 1 ,
103+ 'password' ,
104+ 'somesalt' ,
57105 '7d124315b3ba588668393b2e2d6867bd9f211a4eebd240d0023e540a783a69f0' ,
58- '\$ argon2d\$ v=19\$ m=8,t=2,p=1\$ c29tZXNhbHQ\$ fRJDFbO6WIZoOTsuLWhnvZ8hGk7r0kDQAj5UCng6afA' , Argon2Type .d);
106+ '\$ argon2d\$ v=19\$ m=8,t=2,p=1\$ c29tZXNhbHQ\$ fRJDFbO6WIZoOTsuLWhnvZ8hGk7r0kDQAj5UCng6afA' ,
107+ Argon2Type .d);
59108 expect (code, DArgon2ErrorCode .ARGON2_OK );
60109 });
61110 testWidgets ('v = ${0x13 }, t = 2, m = 16, p = 2,' , (_) async {
62- var code = await hashTest (Argon2Version .V13 , 2 , 16 , 2 , 'password' , 'somesalt' ,
111+ var code = await hashTest (
112+ Argon2Version .V13 ,
113+ 2 ,
114+ 16 ,
115+ 2 ,
116+ 'password' ,
117+ 'somesalt' ,
63118 '59f20a66a4c31bf0438a2f494867c32120409a91380f0687aefee984ba86bda8' ,
64- '\$ argon2d\$ v=19\$ m=16,t=2,p=2\$ c29tZXNhbHQ\$ WfIKZqTDG/BDii9JSGfDISBAmpE4DwaHrv7phLqGvag' , Argon2Type .d);
119+ '\$ argon2d\$ v=19\$ m=16,t=2,p=2\$ c29tZXNhbHQ\$ WfIKZqTDG/BDii9JSGfDISBAmpE4DwaHrv7phLqGvag' ,
120+ Argon2Type .d);
65121 expect (code, DArgon2ErrorCode .ARGON2_OK );
66122 });
67123 });
68124 // Argon2id test group
69125 group ('Hash Tests - Argon2id' , () {
70126 testWidgets ('v = ${0x13 }, t = 2, m = 16, p = 1,' , (_) async {
71- var code = await hashTest (Argon2Version .V13 , 2 , 16 , 1 , 'password' , 'somesalt' ,
127+ var code = await hashTest (
128+ Argon2Version .V13 ,
129+ 2 ,
130+ 16 ,
131+ 1 ,
132+ 'password' ,
133+ 'somesalt' ,
72134 '058202c0723cd88c24408ccac1cbf828dee63bcf3843a150ea364a1e0b4e1ff8' ,
73- '\$ argon2id\$ v=19\$ m=16,t=2,p=1\$ c29tZXNhbHQ\$ BYICwHI82IwkQIzKwcv4KN7mO884Q6FQ6jZKHgtOH/g' , Argon2Type .id);
135+ '\$ argon2id\$ v=19\$ m=16,t=2,p=1\$ c29tZXNhbHQ\$ BYICwHI82IwkQIzKwcv4KN7mO884Q6FQ6jZKHgtOH/g' ,
136+ Argon2Type .id);
74137 expect (code, DArgon2ErrorCode .ARGON2_OK );
75138 });
76139 testWidgets ('v = ${0x13 }, t = 2, m = 18, p = 1,' , (_) async {
77- var code = await hashTest (Argon2Version .V13 , 2 , 18 , 1 , 'password' , 'somesalt' ,
140+ var code = await hashTest (
141+ Argon2Version .V13 ,
142+ 2 ,
143+ 18 ,
144+ 1 ,
145+ 'password' ,
146+ 'somesalt' ,
78147 '0e6408c954c4980f6313756ea01ee7ddebb362efbb20d49d08a6859787024e3f' ,
79- '\$ argon2id\$ v=19\$ m=18,t=2,p=1\$ c29tZXNhbHQ\$ DmQIyVTEmA9jE3VuoB7n3euzYu+7INSdCKaFl4cCTj8' , Argon2Type .id);
148+ '\$ argon2id\$ v=19\$ m=18,t=2,p=1\$ c29tZXNhbHQ\$ DmQIyVTEmA9jE3VuoB7n3euzYu+7INSdCKaFl4cCTj8' ,
149+ Argon2Type .id);
80150 expect (code, DArgon2ErrorCode .ARGON2_OK );
81151 });
82152 testWidgets ('v = ${0x13 }, t = 2, m = 8, p = 1,' , (_) async {
83- var code = await hashTest (Argon2Version .V13 , 2 , 8 , 1 , 'password' , 'somesalt' ,
153+ var code = await hashTest (
154+ Argon2Version .V13 ,
155+ 2 ,
156+ 8 ,
157+ 1 ,
158+ 'password' ,
159+ 'somesalt' ,
84160 'fdb4ddb6d5887131b66f0b2a3740c077dd05b755845861f6b5a1dde8b1071646' ,
85- '\$ argon2id\$ v=19\$ m=8,t=2,p=1\$ c29tZXNhbHQ\$ /bTdttWIcTG2bwsqN0DAd90Ft1WEWGH2taHd6LEHFkY' , Argon2Type .id);
161+ '\$ argon2id\$ v=19\$ m=8,t=2,p=1\$ c29tZXNhbHQ\$ /bTdttWIcTG2bwsqN0DAd90Ft1WEWGH2taHd6LEHFkY' ,
162+ Argon2Type .id);
86163 expect (code, DArgon2ErrorCode .ARGON2_OK );
87164 });
88165 testWidgets ('v = ${0x13 }, t = 2, m = 16, p = 2,' , (_) async {
89- var code = await hashTest (Argon2Version .V13 , 2 , 16 , 2 , 'password' , 'somesalt' ,
166+ var code = await hashTest (
167+ Argon2Version .V13 ,
168+ 2 ,
169+ 16 ,
170+ 2 ,
171+ 'password' ,
172+ 'somesalt' ,
90173 '747d7631b182faf749d7efc31aec31df4ecfe3b57c792f53800ac2c9978b4888' ,
91- '\$ argon2id\$ v=19\$ m=16,t=2,p=2\$ c29tZXNhbHQ\$ dH12MbGC+vdJ1+/DGuwx307P47V8eS9TgArCyZeLSIg' , Argon2Type .id);
174+ '\$ argon2id\$ v=19\$ m=16,t=2,p=2\$ c29tZXNhbHQ\$ dH12MbGC+vdJ1+/DGuwx307P47V8eS9TgArCyZeLSIg' ,
175+ Argon2Type .id);
92176 expect (code, DArgon2ErrorCode .ARGON2_OK );
93177 });
94178 });
95179}
96180
97- Future <DArgon2ErrorCode > hashTest (Argon2Version version, int iterations, int memory, int parallelism, String password, String salt, String hexHash, String encodedHash, Argon2Type type) async {
181+ Future <DArgon2ErrorCode > hashTest (
182+ Argon2Version version,
183+ int iterations,
184+ int memory,
185+ int parallelism,
186+ String password,
187+ String salt,
188+ String hexHash,
189+ String encodedHash,
190+ Argon2Type type) async {
98191 var s = Salt (utf8.encode (salt));
99192 DArgon2Result resultString;
100193 DArgon2Result resultBytes;
101194 // get hashed results
102195 try {
103- resultString = await argon2.hashPasswordString (password, salt: s,
196+ resultString = await argon2.hashPasswordString (password,
197+ salt: s,
104198 iterations: iterations,
105199 memory: memory,
106200 parallelism: parallelism,
107201 version: version,
108202 type: type);
109- resultBytes = await argon2.hashPasswordBytes (utf8.encode (password), salt: s,
203+ resultBytes = await argon2.hashPasswordBytes (utf8.encode (password),
204+ salt: s,
110205 iterations: iterations,
111206 memory: memory,
112207 parallelism: parallelism,
@@ -121,15 +216,20 @@ Future<DArgon2ErrorCode> hashTest(Argon2Version version, int iterations, int mem
121216 return DArgon2ErrorCode .ARGON2_UNKNOWN_ERROR ;
122217 }
123218 // Check if both are verified
124- if (! await argon2.verifyHashString (password, encodedHash, type: type) || ! await argon2.verifyHashBytes (utf8.encode (password), utf8.encode (encodedHash), type: type)) {
219+ if (! await argon2.verifyHashString (password, encodedHash, type: type) ||
220+ ! await argon2.verifyHashBytes (
221+ utf8.encode (password), utf8.encode (encodedHash),
222+ type: type)) {
125223 return DArgon2ErrorCode .ARGON2_UNKNOWN_ERROR ;
126224 }
127225 // Check if both are verified against each other
128- if (! await argon2.verifyHashString (password, resultBytes.encodedString, type: type) || ! await argon2.verifyHashString (password, resultString.encodedString, type: type)) {
226+ if (! await argon2.verifyHashString (password, resultBytes.encodedString,
227+ type: type) ||
228+ ! await argon2.verifyHashString (password, resultString.encodedString,
229+ type: type)) {
129230 return DArgon2ErrorCode .ARGON2_UNKNOWN_ERROR ;
130231 }
131232 return DArgon2ErrorCode .ARGON2_OK ;
132-
133233 } on DArgon2Exception catch (e) {
134234 print ("Catch: $e " );
135235 return e.errorCode;
0 commit comments