Latest update.
This commit is contained in:
+51
-13
@@ -463,6 +463,7 @@ typedef struct cipher_data_st {
|
||||
size_t aad_len[AAD_NUM];
|
||||
unsigned char *tag;
|
||||
size_t tag_len;
|
||||
int tag_late;
|
||||
} CIPHER_DATA;
|
||||
|
||||
static int cipher_test_init(EVP_TEST *t, const char *alg)
|
||||
@@ -535,6 +536,15 @@ static int cipher_test_parse(EVP_TEST *t, const char *keyword,
|
||||
}
|
||||
if (strcmp(keyword, "Tag") == 0)
|
||||
return parse_bin(value, &cdat->tag, &cdat->tag_len);
|
||||
if (strcmp(keyword, "SetTagLate") == 0) {
|
||||
if (strcmp(value, "TRUE") == 0)
|
||||
cdat->tag_late = 1;
|
||||
else if (strcmp(value, "FALSE") == 0)
|
||||
cdat->tag_late = 0;
|
||||
else
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(keyword, "Operation") == 0) {
|
||||
@@ -620,7 +630,7 @@ static int cipher_test_enc(EVP_TEST *t, int enc,
|
||||
* If encrypting or OCB just set tag length initially, otherwise
|
||||
* set tag length and value.
|
||||
*/
|
||||
if (enc || expected->aead == EVP_CIPH_OCB_MODE) {
|
||||
if (enc || expected->aead == EVP_CIPH_OCB_MODE || expected->tag_late) {
|
||||
t->err = "TAG_LENGTH_SET_ERROR";
|
||||
tag = NULL;
|
||||
} else {
|
||||
@@ -643,14 +653,6 @@ static int cipher_test_enc(EVP_TEST *t, int enc,
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!enc && expected->aead == EVP_CIPH_OCB_MODE) {
|
||||
if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG,
|
||||
expected->tag_len, expected->tag)) {
|
||||
t->err = "TAG_SET_ERROR";
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (expected->aead == EVP_CIPH_CCM_MODE) {
|
||||
if (!EVP_CipherUpdate(ctx, NULL, &tmplen, NULL, out_len)) {
|
||||
t->err = "CCM_PLAINTEXT_LENGTH_SET_ERROR";
|
||||
@@ -689,6 +691,15 @@ static int cipher_test_enc(EVP_TEST *t, int enc,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!enc && (expected->aead == EVP_CIPH_OCB_MODE || expected->tag_late)) {
|
||||
if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG,
|
||||
expected->tag_len, expected->tag)) {
|
||||
t->err = "TAG_SET_ERROR";
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
EVP_CIPHER_CTX_set_padding(ctx, 0);
|
||||
t->err = "CIPHERUPDATE_ERROR";
|
||||
tmplen = 0;
|
||||
@@ -1378,6 +1389,7 @@ static int pkey_test_run(EVP_TEST *t)
|
||||
PKEY_DATA *expected = t->data;
|
||||
unsigned char *got = NULL;
|
||||
size_t got_len;
|
||||
EVP_PKEY_CTX *copy = NULL;
|
||||
|
||||
if (expected->keyop(expected->ctx, NULL, &got_len,
|
||||
expected->input, expected->input_len) <= 0
|
||||
@@ -1396,8 +1408,33 @@ static int pkey_test_run(EVP_TEST *t)
|
||||
goto err;
|
||||
|
||||
t->err = NULL;
|
||||
OPENSSL_free(got);
|
||||
got = NULL;
|
||||
|
||||
/* Repeat the test on a copy. */
|
||||
if (!TEST_ptr(copy = EVP_PKEY_CTX_dup(expected->ctx))) {
|
||||
t->err = "INTERNAL_ERROR";
|
||||
goto err;
|
||||
}
|
||||
if (expected->keyop(copy, NULL, &got_len, expected->input,
|
||||
expected->input_len) <= 0
|
||||
|| !TEST_ptr(got = OPENSSL_malloc(got_len))) {
|
||||
t->err = "KEYOP_LENGTH_ERROR";
|
||||
goto err;
|
||||
}
|
||||
if (expected->keyop(copy, got, &got_len, expected->input,
|
||||
expected->input_len) <= 0) {
|
||||
t->err = "KEYOP_ERROR";
|
||||
goto err;
|
||||
}
|
||||
if (!memory_err_compare(t, "KEYOP_MISMATCH",
|
||||
expected->output, expected->output_len,
|
||||
got, got_len))
|
||||
goto err;
|
||||
|
||||
err:
|
||||
OPENSSL_free(got);
|
||||
EVP_PKEY_CTX_free(copy);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1912,7 +1949,7 @@ typedef struct kdf_data_st {
|
||||
static int kdf_test_init(EVP_TEST *t, const char *name)
|
||||
{
|
||||
KDF_DATA *kdata;
|
||||
int kdf_nid = OBJ_sn2nid(name);
|
||||
const EVP_KDF *kdf;
|
||||
|
||||
#ifdef OPENSSL_NO_SCRYPT
|
||||
if (strcmp(name, "scrypt") == 0) {
|
||||
@@ -1921,12 +1958,13 @@ static int kdf_test_init(EVP_TEST *t, const char *name)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (kdf_nid == NID_undef)
|
||||
kdf_nid = OBJ_ln2nid(name);
|
||||
kdf = EVP_get_kdfbyname(name);
|
||||
if (kdf == NULL)
|
||||
return 0;
|
||||
|
||||
if (!TEST_ptr(kdata = OPENSSL_zalloc(sizeof(*kdata))))
|
||||
return 0;
|
||||
kdata->ctx = EVP_KDF_CTX_new_id(kdf_nid);
|
||||
kdata->ctx = EVP_KDF_CTX_new(kdf);
|
||||
if (kdata->ctx == NULL) {
|
||||
OPENSSL_free(kdata);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user