| 1282 | |
| 1283 | |
| 1284 | int pwdbased_test() |
| 1285 | { |
| 1286 | PBKDF2_HMAC<SHA> pb; |
| 1287 | |
| 1288 | byte derived[32]; |
| 1289 | const byte pwd1[] = "password "; // align |
| 1290 | const byte salt[] = { 0x12, 0x34, 0x56, 0x78, 0x78, 0x56, 0x34, 0x12 }; |
| 1291 | |
| 1292 | pb.DeriveKey(derived, 8, pwd1, 8, salt, sizeof(salt), 5); |
| 1293 | |
| 1294 | const byte verify1[] = { 0xD1, 0xDA, 0xA7, 0x86, 0x15, 0xF2, 0x87, 0xE6 }; |
| 1295 | |
| 1296 | if ( memcmp(derived, verify1, sizeof(verify1)) ) |
| 1297 | return -101; |
| 1298 | |
| 1299 | |
| 1300 | const byte pwd2[] = "All n-entities must communicate with other n-entities" |
| 1301 | " via n-1 entiteeheehees "; // align |
| 1302 | |
| 1303 | pb.DeriveKey(derived, 24, pwd2, 76, salt, sizeof(salt), 500); |
| 1304 | |
| 1305 | const byte verify2[] = { 0x6A, 0x89, 0x70, 0xBF, 0x68, 0xC9, 0x2C, 0xAE, |
| 1306 | 0xA8, 0x4A, 0x8D, 0xF2, 0x85, 0x10, 0x85, 0x86, |
| 1307 | 0x07, 0x12, 0x63, 0x80, 0xCC, 0x47, 0xAB, 0x2D |
| 1308 | }; |
| 1309 | |
| 1310 | if ( memcmp(derived, verify2, sizeof(verify2)) ) |
| 1311 | return -102; |
| 1312 | |
| 1313 | return 0; |
| 1314 | } |
| 1315 | |
| 1316 | |
| 1317 | /* |
no test coverage detected