Commit f3c15bda authored by Tomáš Stefan's avatar Tomáš Stefan

add fn sigil_print_digest

prints in hex format ASN1_OCTET_STRING
parent 0c0bf2b3
......@@ -8,8 +8,6 @@
#include "types.h"
void print_computed_hash(sigil_t *sgl);
/** @brief Compute a message digest (hash) for the PKCS#1 signature type
*
* @param sgl context
......
......@@ -121,6 +121,12 @@ sigil_err_t sigil_get_original_digest(sigil_t *sgl, ASN1_OCTET_STRING **digest);
*/
sigil_err_t sigil_get_computed_digest(sigil_t *sgl, ASN1_OCTET_STRING **digest);
/** @brief Print provided message digest to the standard output
*
* @param digest input - digest to be printed
*/
void sigil_print_digest(const ASN1_OCTET_STRING *digest);
/** @brief Gets the subfilter value from the provided context
*
* @param sgl context
......
......@@ -61,20 +61,6 @@ static sigil_err_t hex_to_dec(const char *in, size_t in_len, unsigned char *out,
return ERR_NONE;
}
//void print_computed_hash(sigil_t *sgl)
//{
// if (sgl == NULL || sgl->computed_hash_len <= 0)
// return;
//
// printf("\nCOMPUTED HASH: ");
//
// for (int i = 0; i < sgl->computed_hash_len; i++) {
// printf("%02x ", sgl->computed_hash[i]);
// }
//
// printf("\n");
//}
sigil_err_t compute_digest_pkcs1(sigil_t *sgl)
{
sigil_err_t err;
......
......@@ -413,6 +413,25 @@ sigil_err_t sigil_get_computed_digest(sigil_t *sgl, ASN1_OCTET_STRING **digest)
return ERR_NONE;
}
void sigil_print_digest(const ASN1_OCTET_STRING *digest)
{
const unsigned char *digest_data;
int digest_len;
if (digest == NULL)
return;
digest_len = ASN1_STRING_length(digest);
digest_data = ASN1_STRING_get0_data(digest);
if (digest_len < 0 || digest_data == NULL)
return;
for (int i = 0; i < digest_len; i++) {
printf("%02x ", digest_data[i]);
}
}
sigil_err_t sigil_get_subfilter(sigil_t *sgl, int *subfilter)
{
if (sgl == NULL || subfilter == NULL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment