Improve header docs and rename parameter

Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
David Horstmann 2023-02-21 15:27:16 +00:00
parent 03329970de
commit 59400ffed5
2 changed files with 15 additions and 10 deletions

View file

@ -470,15 +470,20 @@ int mbedtls_oid_get_numeric_string(char *buf, size_t size, const mbedtls_asn1_bu
* \brief Translate a string containing a numeric representation * \brief Translate a string containing a numeric representation
* of an ASN.1 OID into its encoded form * of an ASN.1 OID into its encoded form
* (e.g. "1.2.840.113549" into "\x2A\x86\x48\x86\xF7\x0D") * (e.g. "1.2.840.113549" into "\x2A\x86\x48\x86\xF7\x0D")
* On success, this function allocates oid->buf from the
* heap. It must be free'd by the caller.
* *
* \param buf buffer to put representation in * \param oid mbedtls_asn1_buf to populate with the DER-encoded OID
* \param size size of the buffer * \param oid_str string representation of the OID to parse
* \param oid OID to translate * \param size length of the OID string
* *
* \return Length of the string written (excluding final NULL) or * \return 0 if successful
* MBEDTLS_ERR_OID_BUF_TOO_SMALL in case of error * \return #MBEDTLS_ERR_ASN1_INVALID_DATA if oid_str does not
* represent a valid OID
* \return #MBEDTLS_ERR_ASN1_ALLOC_FAILED if the function fails to
* allocate oid->buf
*/ */
int mbedtls_oid_from_numeric_string(mbedtls_asn1_buf *oid, const char *buf, size_t size); int mbedtls_oid_from_numeric_string(mbedtls_asn1_buf *oid, const char *oid_str, size_t size);
/** /**
* \brief Translate an X.509 extension OID into local values * \brief Translate an X.509 extension OID into local values

View file

@ -948,12 +948,12 @@ static int oid_subidentifier_encode_into(unsigned char **p,
/* Return the OID for the given x.y.z.... style numeric string */ /* Return the OID for the given x.y.z.... style numeric string */
int mbedtls_oid_from_numeric_string(mbedtls_asn1_buf *oid, int mbedtls_oid_from_numeric_string(mbedtls_asn1_buf *oid,
const char *buf, size_t size) const char *oid_str, size_t size)
{ {
int ret = MBEDTLS_ERR_ASN1_INVALID_DATA; int ret = MBEDTLS_ERR_ASN1_INVALID_DATA;
const char *str_ptr = buf; const char *str_ptr = oid_str;
const char *str_bound = buf + size; const char *str_bound = oid_str + size;
int val = 0; int val = 0;
size_t encoded_len; size_t encoded_len;
@ -1020,7 +1020,7 @@ int mbedtls_oid_from_numeric_string(mbedtls_asn1_buf *oid,
oid->len = encoded_len; oid->len = encoded_len;
/* Now that we've allocated the buffer, go back to the start and encode */ /* Now that we've allocated the buffer, go back to the start and encode */
str_ptr = buf; str_ptr = oid_str;
unsigned char *out_ptr = oid->p; unsigned char *out_ptr = oid->p;
unsigned char *out_bound = oid->p + oid->len; unsigned char *out_bound = oid->p + oid->len;