"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/crypto-vectors.c" between
cryptsetup-2.4.1.tar.xz and cryptsetup-2.4.2.tar.xz

About: cryptsetup is a utility used to conveniently setup disk encryption based on the dm-crypt kernel module. These include plain dm-crypt volumes, LUKS volumes, loop-AES and TrueCrypt compatible format.

crypto-vectors.c  (cryptsetup-2.4.1.tar.xz):crypto-vectors.c  (cryptsetup-2.4.2.tar.xz)
skipping to change at line 127 skipping to change at line 127
// "\x04\x04\x04\x04", 12, // "\x04\x04\x04\x04", 12,
"\x03\xaa\xb9\x65\xc1\x20\x01\xc9" "\x03\xaa\xb9\x65\xc1\x20\x01\xc9"
"\xd7\xd0\xd2\xde\x33\x19\x2c\x04" "\xd7\xd0\xd2\xde\x33\x19\x2c\x04"
"\x94\xb6\x84\xbb\x14\x81\x96\xd7" "\x94\xb6\x84\xbb\x14\x81\x96\xd7"
"\x3c\x1d\xf1\xac\xaf\x6d\x0c\x2e", 32 "\x3c\x1d\xf1\xac\xaf\x6d\x0c\x2e", 32
// "\x0d\x64\x0d\xf5\x8d\x78\x76\x6c" // "\x0d\x64\x0d\xf5\x8d\x78\x76\x6c"
// "\x08\xc0\x37\xa3\x4a\x8b\x53\xc9" // "\x08\xc0\x37\xa3\x4a\x8b\x53\xc9"
// "\xd0\x1e\xf0\x45\x2d\x75\xb6\x5e" // "\xd0\x1e\xf0\x45\x2d\x75\xb6\x5e"
// "\xb5\x25\x20\xe9\x6b\x01\xe6\x59", 32 // "\xb5\x25\x20\xe9\x6b\x01\xe6\x59", 32
}, },
/* empty password */
{
"argon2i", NULL, 0, 3, 128, 1,
"", 0,
"\x00\x01\x02\x03\x04\x05\x06\x07"
"\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", 16,
"\xbb\x1f\xf2\xb9\x9f\xd4\x4a\xd9"
"\xdf\x7f\xb9\x54\x55\x9e\xb8\xeb"
"\xb5\x9d\xab\xce\x2e\x62\x9f\x9b"
"\x89\x09\xfe\xde\x57\xcc\x63\x86", 32
},
{
"argon2id", NULL, 0, 3, 128, 1,
"", 0,
"\x00\x01\x02\x03\x04\x05\x06\x07"
"\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", 16,
"\x09\x2f\x38\x35\xac\xb2\x43\x92"
"\x93\xeb\xcd\xe8\x04\x16\x6a\x31"
"\xce\x14\xd4\x55\xdb\xd8\xf7\xe6"
"\xb4\xf5\x9d\x64\x8e\xd0\x3a\xdb", 32
},
/* RFC 3962 */ /* RFC 3962 */
{ {
"pbkdf2", "sha1", 64, 1, 0, 0, "pbkdf2", "sha1", 64, 1, 0, 0,
"password", 8, "password", 8,
"ATHENA.MIT.EDUraeburn", 21, "ATHENA.MIT.EDUraeburn", 21,
"\xcd\xed\xb5\x28\x1b\xb2\xf8\x01" "\xcd\xed\xb5\x28\x1b\xb2\xf8\x01"
"\x56\x5a\x11\x22\xb2\x56\x35\x15" "\x56\x5a\x11\x22\xb2\x56\x35\x15"
"\x0a\xd1\xf7\xa0\x4b\xb9\xf3\xa3" "\x0a\xd1\xf7\xa0\x4b\xb9\xf3\xa3"
"\x33\xec\xc0\xe2\xe1\xf7\x08\x37", 32 "\x33\xec\xc0\xe2\xe1\xf7\x08\x37", 32
}, { }, {
skipping to change at line 941 skipping to change at line 962
"\x95\x10\x45\x5d\xdd\xc4\xcd\x33\xad\xbd\x39\x49\xf2\x85\x82\x4c " "\x95\x10\x45\x5d\xdd\xc4\xcd\x33\xad\xbd\x39\x49\xf2\x85\x82\x4c "
}, },
}}}; }}};
static int pbkdf_test_vectors(void) static int pbkdf_test_vectors(void)
{ {
char result[256]; char result[256];
unsigned int i; unsigned int i;
const struct kdf_test_vector *vec; const struct kdf_test_vector *vec;
for (i = 0; i < (sizeof(kdf_test_vectors) / sizeof(*kdf_test_vectors)); i ++) { for (i = 0; i < ARRAY_SIZE(kdf_test_vectors); i++) {
crypt_backend_memzero(result, sizeof(result)); crypt_backend_memzero(result, sizeof(result));
vec = &kdf_test_vectors[i]; vec = &kdf_test_vectors[i];
printf("PBKDF vector %02d %s ", i, vec->type); printf("PBKDF vector %02d %s ", i, vec->type);
if (vec->hash && crypt_hmac_size(vec->hash) < 0) { if (vec->hash && crypt_hmac_size(vec->hash) < 0) {
printf("[%s N/A]\n", vec->hash); printf("[%s N/A]\n", vec->hash);
continue; continue;
} }
if (crypt_pbkdf(vec->type, vec->hash, if (crypt_pbkdf(vec->type, vec->hash,
vec->password, vec->password_length, vec->password, vec->password_length,
vec->salt, vec->salt_length, vec->salt, vec->salt_length,
skipping to change at line 1035 skipping to change at line 1056
if (crypt_hash_init(&h, vector->out[j].name)) { if (crypt_hash_init(&h, vector->out[j].name)) {
printf("[%s N/A (init)]", vector->out[j].name); printf("[%s N/A (init)]", vector->out[j].name);
continue; continue;
} }
r = crypt_hash_write(h, vector->data, vector->data_length ); r = crypt_hash_write(h, vector->data, vector->data_length );
if (!r) if (!r)
r = crypt_hash_final(h, result, vector->out[j].le ngth); r = crypt_hash_final(h, result, vector->out[j].le ngth);
crypt_hash_destroy(h); if (r) {
crypt_hash_destroy(h);
if (r)
return EXIT_FAILURE; return EXIT_FAILURE;
}
if (memcmp(result, vector->out[j].out, vector->out[j].len gth)) { if (memcmp(result, vector->out[j].out, vector->out[j].len gth)) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printhex(" got", result, vector->out[j].length); printhex(" got", result, vector->out[j].length);
printhex("want", vector->out[j].out, vector->out[ j].length); printhex("want", vector->out[j].out, vector->out[ j].length);
crypt_hash_destroy(h);
return EXIT_FAILURE;
}
/*
* After crypt_hash_final() the context must be reset, re
peat
*/
crypt_backend_memzero(result, sizeof(result));
r = crypt_hash_write(h, vector->data, vector->data_length
);
if (!r)
r = crypt_hash_final(h, result, vector->out[j].le
ngth);
if (r || memcmp(result, vector->out[j].out, vector->out[j
].length)) {
printf("[FAILED (RESET CONTEXT)]\n");
printhex(" got", result, vector->out[j].length);
printhex("want", vector->out[j].out, vector->out[
j].length);
crypt_hash_destroy(h);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
crypt_hash_destroy(h);
} }
printf("\n"); printf("\n");
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
static int hmac_test(void) static int hmac_test(void)
{ {
const struct hmac_test_vector *vector; const struct hmac_test_vector *vector;
skipping to change at line 1088 skipping to change at line 1128
crypt_backend_memzero(result, sizeof(result)); crypt_backend_memzero(result, sizeof(result));
printf("[%s]", vector->out[j].name); printf("[%s]", vector->out[j].name);
if (crypt_hmac_init(&hmac, vector->out[j].name, vector->k ey, vector->key_length)) if (crypt_hmac_init(&hmac, vector->out[j].name, vector->k ey, vector->key_length))
return EXIT_FAILURE; return EXIT_FAILURE;
r = crypt_hmac_write(hmac, vector->data, vector->data_len gth); r = crypt_hmac_write(hmac, vector->data, vector->data_len gth);
if (!r) if (!r)
r = crypt_hmac_final(hmac, result, vector->out[j] .length); r = crypt_hmac_final(hmac, result, vector->out[j] .length);
crypt_hmac_destroy(hmac); if (r) {
crypt_hmac_destroy(hmac);
if (r)
return EXIT_FAILURE; return EXIT_FAILURE;
}
if (memcmp(result, vector->out[j].out, vector->out[j].len gth)) { if (memcmp(result, vector->out[j].out, vector->out[j].len gth)) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printhex(" got", result, vector->out[j].length); printhex(" got", result, vector->out[j].length);
printhex("want", vector->out[j].out, vector->out[ j].length); printhex("want", vector->out[j].out, vector->out[ j].length);
crypt_hmac_destroy(hmac);
return EXIT_FAILURE;
}
/*
* After crypt_hmac_final() the context must be reset, re
peat
*/
crypt_backend_memzero(result, sizeof(result));
r = crypt_hmac_write(hmac, vector->data, vector->data_len
gth);
if (!r)
r = crypt_hmac_final(hmac, result, vector->out[j]
.length);
if (r || memcmp(result, vector->out[j].out, vector->out[j
].length)) {
printf("[FAILED (RESET CONTEXT)]\n");
printhex(" got", result, vector->out[j].length);
printhex("want", vector->out[j].out, vector->out[
j].length);
crypt_hmac_destroy(hmac);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
crypt_hmac_destroy(hmac);
} }
printf("\n"); printf("\n");
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
static int cipher_test(void) static int cipher_test(void)
{ {
const struct cipher_test_vector *vector; const struct cipher_test_vector *vector;
 End of changes. 10 change blocks. 
7 lines changed or deleted 76 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)