Skip to content

Commit d8233f7

Browse files
Andres Amaya Garciasimonbutcher
authored andcommitted
Improve docs for named bitstrings and their usage
1 parent 7067f81 commit d8233f7

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

include/mbedtls/asn1write.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -283,19 +283,21 @@ int mbedtls_asn1_write_bitstring( unsigned char **p, unsigned char *start,
283283
const unsigned char *buf, size_t bits );
284284

285285
/**
286-
* \brief Write a named bitstring tag (MBEDTLS_ASN1_BIT_STRING) and
287-
* value in ASN.1 format
288-
* Note: function works backwards in data buffer
286+
* \brief This function writes a named bitstring tag
287+
* (#MBEDTLS_ASN1_BIT_STRING) and value in ASN.1 format.
289288
*
290-
* As stated in RFC5280 Appending B, trailing zeroes are
289+
* As stated in RFC 5280 Appendix B, trailing zeroes are
291290
* omitted when encoding named bitstrings in DER.
292291
*
293-
* \param p Reference to current position pointer.
294-
* \param start Start of the buffer (for bounds-checking).
295-
* \param buf The bitstring.
292+
* \note This function works backwards within the data buffer.
293+
*
294+
* \param p The reference to the current position pointer.
295+
* \param start The start of the buffer which is used for bounds-checking.
296+
* \param buf The bitstring to write.
296297
* \param bits The total number of bits in the bitstring.
297298
*
298-
* \return The length written or a negative error code.
299+
* \return The number of bytes written to \p p on success.
300+
* \return A negative error code on failure.
299301
*/
300302
int mbedtls_asn1_write_named_bitstring( unsigned char **p,
301303
unsigned char *start,

include/mbedtls/x509_csr.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,14 @@ void mbedtls_x509write_csr_set_md_alg( mbedtls_x509write_csr *ctx, mbedtls_md_ty
205205
* \param key_usage key usage flags to set
206206
*
207207
* \return 0 if successful, or MBEDTLS_ERR_X509_ALLOC_FAILED
208+
*
209+
* \note The <code>decipherOnly</code> flag from the Key Usage
210+
* extension is represented by bit 8 (i.e.
211+
* <code>0x8000</code>), which cannot typically be represented
212+
* in an unsigned char. Therefore, the flag
213+
* <code>decipherOnly</code> (i.e.
214+
* #MBEDTLS_X509_KU_DECIPHER_ONLY) cannot be set using this
215+
* function.
208216
*/
209217
int mbedtls_x509write_csr_set_key_usage( mbedtls_x509write_csr *ctx, unsigned char key_usage );
210218

0 commit comments

Comments
 (0)