diff --git a/include/mbedtls/oid.h b/include/mbedtls/oid.h index ee60f3791c..07cc5d2643 100644 --- a/include/mbedtls/oid.h +++ b/include/mbedtls/oid.h @@ -188,6 +188,11 @@ #define MBEDTLS_OID_OCSP_NOCHECK MBEDTLS_OID_OCSP "\x05" /**< id-pkix-ocsp-nocheck OBJECT IDENTIFIER ::= { id-pkix-ocsp 5 } */ +/* + * OCSP response type OIDs + */ +#define MBEDTLS_OID_OCSP_BASIC MBEDTLS_OID_OCSP "\x01" /**< id-pkix-ocsp-basic OBJECT IDENTIFIER ::= { id-pkix-ocsp 1 } */ + /* * PKCS definition OIDs */ @@ -545,6 +550,17 @@ int mbedtls_oid_get_extended_key_usage( const mbedtls_asn1_buf *oid, const char int mbedtls_oid_get_authority_info_access( const mbedtls_asn1_buf *oid, const char **desc ); +/** + * \brief Translate OCSP ResponseType OID into description + * + * \param oid OID to use + * \param desc place to store string pointer + * + * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND + */ +int mbedtls_oid_get_ocsp_response_type( const mbedtls_asn1_buf *oid, + const char **desc ); + /** * \brief Translate md_type into hash algorithm OID * diff --git a/library/oid.c b/library/oid.c index 11f31aef95..0b2ca6f7f3 100644 --- a/library/oid.c +++ b/library/oid.c @@ -318,6 +318,17 @@ static const mbedtls_oid_descriptor_t oid_authority_info_access[] = FN_OID_TYPED_FROM_ASN1(mbedtls_oid_descriptor_t, authority_info_access, oid_authority_info_access) FN_OID_GET_ATTR1(mbedtls_oid_get_authority_info_access, mbedtls_oid_descriptor_t, authority_info_access, const char *, description) + +static const mbedtls_oid_descriptor_t oid_ocsp_response_type[] = +{ + { ADD_LEN( MBEDTLS_OID_OCSP ), "id-pkix-ocsp", "OCSP" }, + { ADD_LEN( MBEDTLS_OID_OCSP_BASIC ), "id-pkix-ocsp-basic", "OCSP Basic" }, + { NULL, 0, NULL, NULL }, +}; + +FN_OID_TYPED_FROM_ASN1(mbedtls_oid_descriptor_t, ocsp_response_type, oid_ocsp_response_type) +FN_OID_GET_ATTR1(mbedtls_oid_get_ocsp_response_type, mbedtls_oid_descriptor_t, ocsp_response_type, const char *, description) + #endif /* MBEDTLS_X509_USE_C || MBEDTLS_X509_CREATE_C */ #if defined(MBEDTLS_MD_C)