2016-10-26 21:12:48 +00:00
|
|
|
/*
|
2017-06-19 01:21:22 +00:00
|
|
|
* Copyright 1999-2017 The OpenSSL Project Authors. All Rights Reserved.
|
2016-10-26 21:12:48 +00:00
|
|
|
*
|
|
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Internal tests for the asn1 module */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <openssl/asn1.h>
|
|
|
|
#include <openssl/evp.h>
|
|
|
|
#include <openssl/objects.h>
|
|
|
|
#include "testutil.h"
|
2017-08-22 12:35:43 +00:00
|
|
|
#include "internal/nelem.h"
|
2016-10-26 21:12:48 +00:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
*
|
|
|
|
* Test of a_strnid's tbl_standard
|
|
|
|
*
|
|
|
|
***/
|
|
|
|
|
|
|
|
#include "../crypto/asn1/tbl_standard.h"
|
|
|
|
|
2017-11-15 20:04:12 +00:00
|
|
|
static int test_tbl_standard(void)
|
2016-10-26 21:12:48 +00:00
|
|
|
{
|
|
|
|
const ASN1_STRING_TABLE *tmp;
|
|
|
|
int last_nid = -1;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (tmp = tbl_standard, i = 0; i < OSSL_NELEM(tbl_standard); i++, tmp++) {
|
|
|
|
if (tmp->nid < last_nid) {
|
|
|
|
last_nid = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
last_nid = tmp->nid;
|
|
|
|
}
|
|
|
|
|
2017-06-19 01:21:22 +00:00
|
|
|
if (TEST_int_ne(last_nid, 0)) {
|
|
|
|
TEST_info("asn1 tbl_standard: Table order OK");
|
2016-10-26 21:12:48 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2017-06-19 21:58:14 +00:00
|
|
|
TEST_info("asn1 tbl_standard: out of order");
|
2016-10-26 21:12:48 +00:00
|
|
|
for (tmp = tbl_standard, i = 0; i < OSSL_NELEM(tbl_standard); i++, tmp++)
|
2017-06-19 21:58:14 +00:00
|
|
|
TEST_note("asn1 tbl_standard: Index %zu, NID %d, Name=%s",
|
2017-06-19 01:21:22 +00:00
|
|
|
i, tmp->nid, OBJ_nid2ln(tmp->nid));
|
2016-10-26 21:12:48 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
*
|
|
|
|
* Test of ameth_lib's standard_methods
|
|
|
|
*
|
|
|
|
***/
|
|
|
|
|
|
|
|
#include "internal/asn1_int.h"
|
|
|
|
#include "../crypto/asn1/standard_methods.h"
|
|
|
|
|
2017-11-15 20:04:12 +00:00
|
|
|
static int test_standard_methods(void)
|
2016-10-26 21:12:48 +00:00
|
|
|
{
|
|
|
|
const EVP_PKEY_ASN1_METHOD **tmp;
|
|
|
|
int last_pkey_id = -1;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (tmp = standard_methods, i = 0; i < OSSL_NELEM(standard_methods);
|
|
|
|
i++, tmp++) {
|
|
|
|
if ((*tmp)->pkey_id < last_pkey_id) {
|
|
|
|
last_pkey_id = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
last_pkey_id = (*tmp)->pkey_id;
|
|
|
|
}
|
|
|
|
|
2017-06-19 01:21:22 +00:00
|
|
|
if (TEST_int_ne(last_pkey_id, 0)) {
|
|
|
|
TEST_info("asn1 standard methods: Table order OK");
|
2016-10-26 21:12:48 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2017-06-19 21:58:14 +00:00
|
|
|
TEST_note("asn1 standard methods: out of order");
|
2016-10-26 21:12:48 +00:00
|
|
|
for (tmp = standard_methods, i = 0; i < OSSL_NELEM(standard_methods);
|
|
|
|
i++, tmp++)
|
2017-06-19 21:58:14 +00:00
|
|
|
TEST_note("asn1 standard methods: Index %zu, pkey ID %d, Name=%s",
|
|
|
|
i, (*tmp)->pkey_id, OBJ_nid2sn((*tmp)->pkey_id));
|
2016-10-26 21:12:48 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-07-18 01:48:27 +00:00
|
|
|
int setup_tests(void)
|
2016-10-26 21:12:48 +00:00
|
|
|
{
|
2016-11-03 16:15:41 +00:00
|
|
|
ADD_TEST(test_tbl_standard);
|
|
|
|
ADD_TEST(test_standard_methods);
|
2017-07-18 01:48:27 +00:00
|
|
|
return 1;
|
2016-10-26 21:12:48 +00:00
|
|
|
}
|