-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define "MD light" subset of MD #7120
Changes from all commits
ba2412f
b9b630d
9e04b5b
82a4394
f3953c8
39a4f42
cacc0ea
0d41521
623c73b
1e57abd
45cef61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
/** | ||
* \file md.h | ||
* | ||
* \brief This file contains the generic message-digest wrapper. | ||
* \brief This file contains the generic functions for message-digest | ||
* (hashing) and HMAC. | ||
* | ||
* \author Adriaan de Jong <dejong@fox-it.com> | ||
*/ | ||
|
@@ -107,30 +108,6 @@ typedef struct mbedtls_md_context_t { | |
void *MBEDTLS_PRIVATE(hmac_ctx); | ||
} mbedtls_md_context_t; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated to this line, but rather about this file: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We usually don't guard function declarations in header files with the corresponding implementation macro. For example, before this PR they were not guarded with |
||
/** | ||
* \brief This function returns the list of digests supported by the | ||
* generic digest module. | ||
* | ||
* \note The list starts with the strongest available hashes. | ||
* | ||
* \return A statically allocated array of digests. Each element | ||
* in the returned list is an integer belonging to the | ||
* message-digest enumeration #mbedtls_md_type_t. | ||
* The last entry is 0. | ||
*/ | ||
const int *mbedtls_md_list(void); | ||
|
||
/** | ||
* \brief This function returns the message-digest information | ||
* associated with the given digest name. | ||
* | ||
* \param md_name The name of the digest to search for. | ||
* | ||
* \return The message-digest information associated with \p md_name. | ||
* \return NULL if the associated message-digest information is not found. | ||
*/ | ||
const mbedtls_md_info_t *mbedtls_md_info_from_string(const char *md_name); | ||
|
||
/** | ||
* \brief This function returns the message-digest information | ||
* associated with the given digest type. | ||
|
@@ -142,19 +119,6 @@ const mbedtls_md_info_t *mbedtls_md_info_from_string(const char *md_name); | |
*/ | ||
const mbedtls_md_info_t *mbedtls_md_info_from_type(mbedtls_md_type_t md_type); | ||
|
||
/** | ||
* \brief This function returns the message-digest information | ||
* from the given context. | ||
* | ||
* \param ctx The context from which to extract the information. | ||
* This must be initialized (or \c NULL). | ||
* | ||
* \return The message-digest information associated with \p ctx. | ||
* \return \c NULL if \p ctx is \c NULL. | ||
*/ | ||
const mbedtls_md_info_t *mbedtls_md_info_from_ctx( | ||
const mbedtls_md_context_t *ctx); | ||
|
||
/** | ||
* \brief This function initializes a message-digest context without | ||
* binding it to a particular message-digest algorithm. | ||
|
@@ -248,17 +212,6 @@ unsigned char mbedtls_md_get_size(const mbedtls_md_info_t *md_info); | |
*/ | ||
mbedtls_md_type_t mbedtls_md_get_type(const mbedtls_md_info_t *md_info); | ||
|
||
/** | ||
* \brief This function extracts the message-digest name from the | ||
* message-digest information structure. | ||
* | ||
* \param md_info The information structure of the message-digest algorithm | ||
* to use. | ||
* | ||
* \return The name of the message digest. | ||
*/ | ||
const char *mbedtls_md_get_name(const mbedtls_md_info_t *md_info); | ||
|
||
/** | ||
* \brief This function starts a message-digest computation. | ||
* | ||
|
@@ -337,6 +290,54 @@ MBEDTLS_CHECK_RETURN_TYPICAL | |
int mbedtls_md(const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen, | ||
unsigned char *output); | ||
|
||
/** | ||
* \brief This function returns the list of digests supported by the | ||
* generic digest module. | ||
* | ||
* \note The list starts with the strongest available hashes. | ||
* | ||
* \return A statically allocated array of digests. Each element | ||
* in the returned list is an integer belonging to the | ||
* message-digest enumeration #mbedtls_md_type_t. | ||
* The last entry is 0. | ||
*/ | ||
const int *mbedtls_md_list(void); | ||
|
||
/** | ||
* \brief This function returns the message-digest information | ||
* associated with the given digest name. | ||
* | ||
* \param md_name The name of the digest to search for. | ||
* | ||
* \return The message-digest information associated with \p md_name. | ||
* \return NULL if the associated message-digest information is not found. | ||
*/ | ||
const mbedtls_md_info_t *mbedtls_md_info_from_string(const char *md_name); | ||
|
||
/** | ||
* \brief This function extracts the message-digest name from the | ||
* message-digest information structure. | ||
* | ||
* \param md_info The information structure of the message-digest algorithm | ||
* to use. | ||
* | ||
* \return The name of the message digest. | ||
*/ | ||
const char *mbedtls_md_get_name(const mbedtls_md_info_t *md_info); | ||
|
||
/** | ||
* \brief This function returns the message-digest information | ||
* from the given context. | ||
* | ||
* \param ctx The context from which to extract the information. | ||
* This must be initialized (or \c NULL). | ||
* | ||
* \return The message-digest information associated with \p ctx. | ||
* \return \c NULL if \p ctx is \c NULL. | ||
*/ | ||
const mbedtls_md_info_t *mbedtls_md_info_from_ctx( | ||
const mbedtls_md_context_t *ctx); | ||
|
||
#if defined(MBEDTLS_FS_IO) | ||
/** | ||
* \brief This function calculates the message-digest checksum | ||
|
@@ -471,10 +472,6 @@ int mbedtls_md_hmac(const mbedtls_md_info_t *md_info, const unsigned char *key, | |
const unsigned char *input, size_t ilen, | ||
unsigned char *output); | ||
|
||
/* Internal use */ | ||
MBEDTLS_CHECK_RETURN_TYPICAL | ||
int mbedtls_md_process(mbedtls_md_context_t *ctx, const unsigned char *data); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.