int aws_sha256_hmac_compute()

in source/hmac.c [63:87]


int aws_sha256_hmac_compute(
    struct aws_allocator *allocator,
    const struct aws_byte_cursor *secret,
    const struct aws_byte_cursor *to_hmac,
    struct aws_byte_buf *output,
    size_t truncate_to) {
    struct aws_hmac *hmac = aws_sha256_hmac_new(allocator, secret);

    if (!hmac) {
        return AWS_OP_ERR;
    }

    if (aws_hmac_update(hmac, to_hmac)) {
        aws_hmac_destroy(hmac);
        return AWS_OP_ERR;
    }

    if (aws_hmac_finalize(hmac, output, truncate_to)) {
        aws_hmac_destroy(hmac);
        return AWS_OP_ERR;
    }

    aws_hmac_destroy(hmac);
    return AWS_OP_SUCCESS;
}