mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-11-02 09:33:20 +03:00
Generalized the x509write_csr_set_key_usage() function and key_usage
storage
This commit is contained in:
@@ -93,7 +93,10 @@
|
||||
/** Returns the size of the binary string, without the trailing \\0 */
|
||||
#define OID_SIZE(x) (sizeof(x) - 1)
|
||||
|
||||
/** Compares two asn1_buf structures for the same OID */
|
||||
/** Compares two asn1_buf structures for the same OID. Only works for
|
||||
* 'defined' oid_str values (OID_HMAC_SHA1), you cannot use a 'unsigned
|
||||
* char *oid' here!
|
||||
*/
|
||||
#define OID_CMP(oid_str, oid_buf) \
|
||||
( ( OID_SIZE(oid_str) == (oid_buf)->len ) && \
|
||||
memcmp( (oid_str), (oid_buf)->p, (oid_buf)->len) == 0 )
|
||||
@@ -139,6 +142,17 @@ typedef struct _asn1_sequence
|
||||
}
|
||||
asn1_sequence;
|
||||
|
||||
/**
|
||||
* Container for a sequence or list of 'named' ASN.1 data items
|
||||
*/
|
||||
typedef struct _asn1_named_data
|
||||
{
|
||||
asn1_buf oid; /**< The object identifier. */
|
||||
asn1_buf val; /**< The named value. */
|
||||
struct _asn1_named_data *next; /**< The next entry in the sequence. */
|
||||
}
|
||||
asn1_named_data;
|
||||
|
||||
/**
|
||||
* Get the length of an ASN.1 element.
|
||||
* Updates the pointer to immediately behind the length.
|
||||
@@ -286,6 +300,25 @@ int asn1_get_alg_null( unsigned char **p,
|
||||
const unsigned char *end,
|
||||
asn1_buf *alg );
|
||||
|
||||
/**
|
||||
* Find a specific named_data entry in a sequence or list based on the OID.
|
||||
*
|
||||
* \param list The list to seek through
|
||||
* \param oid The OID to look for
|
||||
* \param len Size of the OID
|
||||
*
|
||||
* \return NULL if not found, or a pointer to the existing entry.
|
||||
*/
|
||||
asn1_named_data *asn1_find_named_data( asn1_named_data *list,
|
||||
const char *oid, size_t len );
|
||||
|
||||
/**
|
||||
* Free a asn1_named_data entry
|
||||
*
|
||||
* \param entry The named data entry to free
|
||||
*/
|
||||
void asn1_free_named_data( asn1_named_data *entry );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user