// File: /workspace/github_c_makefile_star2_O0/xiaowenhuyuehu[P]remote_access/src/utility/sha256/hmac-sha256.c
// Function: hmac_sha256
void
hmac_sha256 (uint8_t out[HMAC_SHA256_DIGEST_SIZE],
             const uint8_t *data, size_t data_len,
             const uint8_t *key, size_t key_len)
{
    api_check_return (out);
    api_check_return (data);
    api_check_return (key);
    api_check_return (key_len <= B);

    sha256_t ss;
#if defined(API_CHECK_DISABLE) && API_CHECK_DISABLE
    uint8_t kh[SHA256_DIGEST_SIZE];
    /*
     * If the key length is bigger than the buffer size B, apply the hash
     * function to it first and use the result instead.
     */
    if (key_len > B) {
        sha256_init (&ss);
        sha256_update (&ss, key, key_len);
        sha256_final (&ss, kh);
        key_len = SHA256_DIGEST_SIZE;
        key = kh;
    }
#endif
    /*
     * (1) append zeros to the end of K to create a B byte string
     *     (e.g., if K is of length 20 bytes and B=64, then K will be
     *     appended with 44 zero bytes 0x00)
     * (2) XOR (bitwise exclusive-OR) the B byte string computed in step
     *     (1) with ipad
     */
    uint8_t kx[B];
    size_t i = 0;
    for (i = 0; i < key_len; i++) kx[i] = I_PAD ^ key[i];
    for (i = key_len; i < B; i++) kx[i] = I_PAD ^ 0;

    /*
     * (3) append the stream of data 'text' to the B byte string resulting
     *     from step (2)
     * (4) apply H to the stream generated in step (3)
     */
    sha256_init (&ss);
    sha256_update (&ss, kx, B);
    sha256_update (&ss, data, data_len);
    sha256_final (&ss, out);

    /*
     * (5) XOR (bitwise exclusive-OR) the B byte string computed in
     *     step (1) with opad
     *
     * NOTE: The "kx" variable is reused.
     */
    for (i = 0; i < key_len; i++) kx[i] = O_PAD ^ key[i];
    for (i = key_len; i < B; i++) kx[i] = O_PAD ^ 0;

    /*
     * (6) append the H result from step (4) to the B byte string
     *     resulting from step (5)
     * (7) apply H to the stream generated in step (6) and output
     *     the result
     */
    sha256_init (&ss);
    sha256_update (&ss, kx, B);
    sha256_update (&ss, out, SHA256_DIGEST_SIZE);
    sha256_final (&ss, out);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x5224
movq 0x9e23(%rip), %rax      # 0xeff0
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x51e9
movq 0x9e0e(%rip), %rax      # 0xeff0
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x627d(%rip), %rsi      # 0xb471
leaq 0x629b(%rip), %rdx      # 0xb496
leaq 0x6298(%rip), %rcx      # 0xb49a
leaq 0x629d(%rip), %r8       # 0xb4a6
movl $0x23, %r9d
movb $0x0, %al
callq 0x2520
movq -0x30(%rbp), %rdi
callq 0x25c0
jmp 0x5509
jmp 0x5226
jmp 0x5228
cmpq $0x0, -0x10(%rbp)
jne 0x528d
movq 0x9dba(%rip), %rax      # 0xeff0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x5252
movq 0x9da5(%rip), %rax      # 0xeff0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
leaq 0x6214(%rip), %rsi      # 0xb471
leaq 0x6263(%rip), %rdx      # 0xb4c7
leaq 0x622f(%rip), %rcx      # 0xb49a
leaq 0x6234(%rip), %r8       # 0xb4a6
movl $0x24, %r9d
movb $0x0, %al
callq 0x2520
movq -0x38(%rbp), %rdi
callq 0x25c0
jmp 0x5509
jmp 0x528f
jmp 0x5291
cmpq $0x0, -0x20(%rbp)
jne 0x52f6
movq 0x9d51(%rip), %rax      # 0xeff0
movq (%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x52bb
movq 0x9d3c(%rip), %rax      # 0xeff0
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
leaq 0x61ab(%rip), %rsi      # 0xb471
leaq 0x6d13(%rip), %rdx      # 0xbfe0
leaq 0x61c6(%rip), %rcx      # 0xb49a
leaq 0x61cb(%rip), %r8       # 0xb4a6
movl $0x25, %r9d
movb $0x0, %al
callq 0x2520
movq -0x40(%rbp), %rdi
callq 0x25c0
jmp 0x5509
jmp 0x52f8
jmp 0x52fa
cmpq $0x40, -0x28(%rbp)
jbe 0x535f
movq 0x9ce8(%rip), %rax      # 0xeff0
movq (%rax), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x5324
movq 0x9cd3(%rip), %rax      # 0xeff0
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
leaq 0x6142(%rip), %rsi      # 0xb471
leaq 0x6196(%rip), %rdx      # 0xb4cc
leaq 0x615d(%rip), %rcx      # 0xb49a
leaq 0x6162(%rip), %r8       # 0xb4a6
movl $0x26, %r9d
movb $0x0, %al
callq 0x2520
movq -0x48(%rbp), %rdi
callq 0x25c0
jmp 0x5509
jmp 0x5361
movq $0x0, -0xf8(%rbp)
movq $0x0, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x53ba
movq -0x20(%rbp), %rax
movq -0xf8(%rbp), %rcx
movzbl (%rax,%rcx), %eax
xorl $0x36, %eax
movb %al, %cl
movq -0xf8(%rbp), %rax
movb %cl, -0xf0(%rbp,%rax)
movq -0xf8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xf8(%rbp)
jmp 0x5377
movq -0x28(%rbp), %rax
movq %rax, -0xf8(%rbp)
cmpq $0x40, -0xf8(%rbp)
jae 0x53f2
movq -0xf8(%rbp), %rax
movb $0x36, -0xf0(%rbp,%rax)
movq -0xf8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xf8(%rbp)
jmp 0x53c5
leaq -0xb0(%rbp), %rdi
callq 0x5520
leaq -0xf0(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
movl $0x40, %edx
callq 0x55e0
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
callq 0x55e0
movq -0x8(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x5670
movq $0x0, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x5488
movq -0x20(%rbp), %rax
movq -0xf8(%rbp), %rcx
movzbl (%rax,%rcx), %eax
xorl $0x5c, %eax
movb %al, %cl
movq -0xf8(%rbp), %rax
movb %cl, -0xf0(%rbp,%rax)
movq -0xf8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xf8(%rbp)
jmp 0x5445
movq -0x28(%rbp), %rax
movq %rax, -0xf8(%rbp)
cmpq $0x40, -0xf8(%rbp)
jae 0x54c0
movq -0xf8(%rbp), %rax
movb $0x5c, -0xf0(%rbp,%rax)
movq -0xf8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xf8(%rbp)
jmp 0x5493
leaq -0xb0(%rbp), %rdi
callq 0x5520
leaq -0xf0(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
movl $0x40, %edx
callq 0x55e0
movq -0x8(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
movl $0x20, %edx
callq 0x55e0
movq -0x8(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x5670
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nop
nopw %cs:(%rax,%rax)
nop