-
Notifications
You must be signed in to change notification settings - Fork 5
Add more generic functions for calculating/checking ICV. #30
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -30,11 +30,12 @@ | |
| # include <unistd.h> | ||
|
|
||
| # include "../basic.h" | ||
| # include "../operators.h" | ||
|
|
||
| # include <openssl/err.h> | ||
| # include <openssl/x509v3.h> | ||
|
|
||
| # include "../storage/uta_api.h" | ||
|
|
||
| static const char *const | ||
| UTIL_SECUTILS_NAME = "secutils"; /*!< short name of this library */ | ||
| static const int UTIL_max_path_len = 512; /*!< max length of file path name */ | ||
|
|
@@ -370,6 +371,7 @@ size_t UTIL_url_encode(const char *source, | |
| # define HEX_BITS 4 | ||
| # define HEX_MASK 0x0f | ||
| # define MAX_DIGIT 9 | ||
|
Comment on lines
371
to
373
Member
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. Please add the prefix |
||
| # define ICV_LEN16 16 | ||
|
Member
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. Why the strange name |
||
|
|
||
| /*! | ||
| * @brief The function converts a binary string into a sequence of hex values. | ||
|
|
@@ -435,4 +437,33 @@ int UTIL_base64_encode_to_buf(const unsigned char *data, int len, | |
| unsigned char *UTIL_base64_decode(const char *b64_data, int b64_len, | ||
| int *decoded_len); | ||
|
|
||
| /*! | ||
| * @brief derive integrity protection hash for data with given len, using key as DV. | ||
|
Member
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. hash -> HMAC |
||
| * | ||
| * @param ctx pointer to uta context object | ||
|
Member
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. add: |
||
| * @param data pointer to data from which the ICV will be calculated | ||
| * @param data_len size of data from which the ICV will be calculated | ||
| * @param key_dv The derivation value for key for which the ICV is calculated | ||
|
Member
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. -> |
||
| * @param icv_out Pointer to a buffer where the resulting ICV will be stored. This buffer must be at least | ||
| * ICV_LEN16 in size. | ||
| * @return true if calculating the ICV is successful, false otherwise | ||
| */ | ||
| bool UTIL_calculate_icv(uta_ctx* ctx, const unsigned char* data, const size_t data_len, const char* key_dv, | ||
|
Member
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.
|
||
| unsigned char* icv_out); | ||
|
|
||
| /*! | ||
| * @brief implementation of the function UTIL_calculate_icv. | ||
| * @note this function was created to avoid code repetition (the same computation is needed in files_icv.c). | ||
| * | ||
| * @param ctx pointer to uta context object | ||
| * @param data pointer to data from which the ICV will be calculated | ||
| * @param data_len size of data from which the ICV will be calculated | ||
| * @param key_dv The derivation value for key for which the ICV is calculated | ||
| * @param mac Pointer to a buffer where the resulting ICV will be stored. This buffer must be at least | ||
| * ICV_LEN16 in size. | ||
| * @return true if calculating the ICV is successful, false otherwise | ||
| */ | ||
| bool UTIL_calculate_icv_impl(uta_ctx* ctx, const unsigned char* data, const size_t data_len, const char* key_dv, | ||
| unsigned char* mac); | ||
|
Member
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.
|
||
|
|
||
|
Comment on lines
+454
to
+468
Member
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. This internal function should not be exported. |
||
| #endif /* SECUTILS_UTIL_H_ */ | ||
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.
add:
. It may be null if and only if SECUTILS_USE_UTA is not defined.