// File: /workspace/github_c_makefile_star2_O2/OpenKMIP[P]libkmip/tests/tests.c
// Function: test_decode_attestation_credential
int
test_decode_attestation_credential(TestTracker *tracker)
{
    TRACK_TEST(tracker);

    uint8 encoding[128] = {
        0x42, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x70,
        0x42, 0x00, 0xC8, 0x01, 0x00, 0x00, 0x00, 0x20,
        0x42, 0x00, 0xC9, 0x08, 0x00, 0x00, 0x00, 0x04,
        0x01, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00,
        0x42, 0x00, 0xCA, 0x08, 0x00, 0x00, 0x00, 0x06,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
        0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
        0x42, 0x00, 0xCB, 0x08, 0x00, 0x00, 0x00, 0x10,
        0x22, 0x22, 0x22, 0x22, 0x44, 0x44, 0x44, 0x44,
        0x66, 0x66, 0x66, 0x66, 0x88, 0x88, 0x88, 0x88,
        0x42, 0x00, 0xCC, 0x08, 0x00, 0x00, 0x00, 0x14,
        0x11, 0x11, 0x11, 0x11, 0x33, 0x33, 0x33, 0x33,
        0x55, 0x55, 0x55, 0x55, 0x77, 0x77, 0x77, 0x77,
        0x99, 0x99, 0x99, 0x99, 0x00, 0x00, 0x00, 0x00
    };
    
    struct kmip ctx = {0};
    kmip_init(&ctx, encoding, ARRAY_LENGTH(encoding), KMIP_1_2);
    
    uint8 nonce_id[4] = {0x01, 0x02, 0x03, 0x04};
    struct byte_string ni = {0};
    ni.value = nonce_id;
    ni.size = ARRAY_LENGTH(nonce_id);
    
    uint8 nonce_value[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
    struct byte_string nv = {0};
    nv.value = nonce_value;
    nv.size = ARRAY_LENGTH(nonce_value);
    
    struct nonce n = {0};
    n.nonce_id = &ni;
    n.nonce_value = &nv;
    
    uint8 measurement[16] = {
        0x22, 0x22, 0x22, 0x22, 0x44, 0x44, 0x44, 0x44,
        0x66, 0x66, 0x66, 0x66, 0x88, 0x88, 0x88, 0x88
    };
    struct byte_string am = {0};
    am.value = measurement;
    am.size = ARRAY_LENGTH(measurement);
    
    uint8 assertion[20] = {
        0x11, 0x11, 0x11, 0x11, 0x33, 0x33, 0x33, 0x33,
        0x55, 0x55, 0x55, 0x55, 0x77, 0x77, 0x77, 0x77,
        0x99, 0x99, 0x99, 0x99
    };
    struct byte_string aa = {0};
    aa.value = assertion;
    aa.size = ARRAY_LENGTH(assertion);
    
    struct attestation_credential expected = {0};
    expected.nonce = &n;
    expected.attestation_type = KMIP_ATTEST_TPM_QUOTE;
    expected.attestation_measurement = &am;
    expected.attestation_assertion = &aa;
    
    struct attestation_credential observed = {0};
    
    int result = kmip_decode_attestation_credential(&ctx, &observed);
    result = report_decoding_test_result(
        tracker,
        &ctx,
        kmip_compare_attestation_credential(&expected, &observed),
        result,
        __func__);
    kmip_free_attestation_credential(&ctx, &observed);
    kmip_destroy(&ctx);
    return(result);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x9f0, %rsp            # imm = 0x9F0
movq %rdi, %r14
incw (%rdi)
leaq 0x1bcf4(%rip), %rsi     # 0x2ad20
pushq $0x10
popq %rcx
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x158(%rsp), %rbx
movl $0x898, %edx            # imm = 0x898
movq %rbx, %rdi
xorl %esi, %esi
callq 0x10c0
pushq $0x2
popq %rcx
movl $0x80, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x128ed
leaq 0x4(%rsp), %rax
movl $0x4030201, (%rax)      # imm = 0x4030201
leaq 0x60(%rsp), %rcx
leaq 0x8(%rsp), %rdx
orw $-0x1, 0x4(%rdx)
movq %rax, (%rcx)
orl $-0x1, (%rdx)
movq $0x4, 0x8(%rcx)
leaq 0x50(%rsp), %rax
movq %rdx, (%rax)
movq $0x6, 0x8(%rax)
leaq 0x40(%rsp), %rdx
movq %rcx, (%rdx)
movq %rax, 0x8(%rdx)
movaps 0x1710e(%rip), %xmm0    # 0x261c0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
leaq 0x30(%rsp), %rcx
movq %rax, (%rcx)
movq $0x10, 0x8(%rcx)
movaps 0x1bccf(%rip), %xmm0    # 0x2ada0
leaq 0x70(%rsp), %rax
movaps %xmm0, (%rax)
movl $0x99999999, 0x10(%rax) # imm = 0x99999999
leaq 0x20(%rsp), %rsi
movq %rax, (%rsi)
movq $0x14, 0x8(%rsi)
leaq 0xb0(%rsp), %r15
andq $0x0, 0x8(%r15)
movq %rdx, (%r15)
movl $0x1, 0x8(%r15)
movq %rcx, 0x10(%r15)
movq %rsi, 0x18(%r15)
xorps %xmm0, %xmm0
leaq 0x90(%rsp), %r12
movaps %xmm0, 0x10(%r12)
movaps %xmm0, (%r12)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1fdf3
movl %eax, %ebp
movq %r15, %rdi
movq %r12, %rsi
callq 0x15e64
leaq 0x18f57(%rip), %r8      # 0x2809c
movq %r14, %rdi
movq %rbx, %rsi
movl %eax, %edx
movl %ebp, %ecx
callq 0x134d
movl %eax, %ebp
movq %rbx, %rdi
movq %r12, %rsi
callq 0x13e78
movq %rbx, %rdi
callq 0x12ade
movl %ebp, %eax
addq $0x9f0, %rsp            # imm = 0x9F0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq