*
* @param[in] algo Digest algorithm (select #YACA_DIGEST_SHA256 if unsure)
* @param[in] data Data from which the digest is to be calculated
- * @param[in] data_len Length of the data
+ * @param[in] data_len Length of the data. Can be 0.
* @param[out] digest Message digest, will be allocated by the library
* @param[out] digest_len Length of message digest (depends on algorithm)
*
* @return #YACA_ERROR_NONE on success, negative on error
* @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
* invalid algo)
* @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
* @retval #YACA_ERROR_INTERNAL Internal error
char *ldigest = NULL;
size_t ldigest_len;
- if (data == NULL || data_len == 0 || digest == NULL || digest_len == NULL)
+ if ((data == NULL && data_len > 0) || digest == NULL || digest_len == NULL)
return YACA_ERROR_INVALID_PARAMETER;
ret = yaca_digest_initialize(&ctx, algo);
if (ret != YACA_ERROR_NONE)
return ret;
- ret = yaca_digest_update(ctx, data, data_len);
- if (ret != YACA_ERROR_NONE)
- goto exit;
+ if (data_len > 0) {
+ ret = yaca_digest_update(ctx, data, data_len);
+ if (ret != YACA_ERROR_NONE)
+ goto exit;
+ }
ret = yaca_context_get_output_length(ctx, 0, &ldigest_len);
if (ret != YACA_ERROR_NONE)