/* fast_sha256_vector - SHA256 hash for data vector @num_elem: Number of elements in the data vector @addr: Pointers to the data areas @len: Lengths of the data blocks @mac: Buffer for the hash Returns: 0 on success, -1 of failure  */
int fast_sha256_vector(size_t num_elem, const uint8_t *addr[], const size_t *len, uint8_t *mac)
/* fast_sha256_vector - SHA256 hash for data vector @num_elem: Number of elements in the data vector @addr: Pointers to the data areas @len: Lengths of the data blocks @mac: Buffer for the hash Returns: 0 on success, -1 of failure  */
int fast_sha256_vector(size_t num_elem, const uint8_t *addr[], const size_t *len, uint8_t *mac)
{
    int ret = 0;
    mbedtls_sha256_context ctx;
    mbedtls_sha256_init(&ctx);
    if (mbedtls_sha256_starts_ret(&ctx, 0) != 0) {
        ret = -1;
        goto out;
    }
    for(size_t index = 0; index < num_elem; index++) {
        if (mbedtls_sha256_update_ret(&ctx, addr[index], len[index]) != 0) {
            ret = -1;
            goto out;
        }
    }
    if (mbedtls_sha256_finish_ret(&ctx, mac) != 0) {
        ret = -1;
        goto out;
    }
out:
    mbedtls_sha256_free(&ctx);
    return ret;
}