1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Merge remote-tracking branch 'origin/pr/2531' into development

Ensure tests pass when the submodule is used by updating the list of
crypto tests to include test_suite_oid in both tests/CMakeLists.txt and
tests/Makefile.

* origin/pr/2531:
  Add changeLog entry
  Add certificate policy of type any policy id
This commit is contained in:
Jaeden Amero
2019-03-27 14:50:21 +00:00
7 changed files with 72 additions and 0 deletions

View File

@ -116,6 +116,7 @@ if(NOT USE_CRYPTO_SUBMODULE)
add_test_suite(memory_buffer_alloc)
add_test_suite(mpi)
add_test_suite(nist_kw)
add_test_suite(oid)
add_test_suite(pem)
add_test_suite(pkcs1_v15)
add_test_suite(pkcs1_v21)

View File

@ -97,6 +97,7 @@ APPS := $(filter-out \
test_suite_memory_buffer_alloc \
test_suite_mpi \
test_suite_nist_kw \
test_suite_oid \
test_suite_pem \
test_suite_pk \
test_suite_pkcs1_v15 \

View File

@ -0,0 +1,8 @@
OID get Any Policy certificate policy
oid_get_certificate_policies:"551D2000":"Any Policy"
OID get certificate policy invalid oid
oid_get_certificate_policies:"5533445566":""
OID get certificate policy wrong oid - id-ce-authorityKeyIdentifier
oid_get_certificate_policies:"551D23":""

View File

@ -0,0 +1,34 @@
/* BEGIN_HEADER */
#include "mbedtls/oid.h"
#include "mbedtls/asn1.h"
#include "mbedtls/asn1write.h"
#include "string.h"
/* END_HEADER */
/* BEGIN_DEPENDENCIES
* depends_on:MBEDTLS_OID_C
* END_DEPENDENCIES
*/
/* BEGIN_CASE depends_on:MBEDTLS_ASN1_WRITE_C*/
void oid_get_certificate_policies( data_t * oid, char * result_str )
{
mbedtls_asn1_buf asn1_buf = { 0, 0, NULL };
int ret;
const char *desc;
asn1_buf.tag = MBEDTLS_ASN1_OID;
asn1_buf.p = oid->x;
asn1_buf.len = oid->len;
ret = mbedtls_oid_get_certificate_policies( &asn1_buf, &desc );
if( strlen( result_str ) == 0 )
{
TEST_ASSERT( ret == MBEDTLS_ERR_OID_NOT_FOUND );
}
else
{
TEST_ASSERT( strcmp( ( char* )desc, result_str ) == 0 );
}
}
/* END_CASE */