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

    uint8 expected[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
    };
    
    uint8 observed[128] = {0};
    struct kmip ctx = {0};
    kmip_init(&ctx, observed, ARRAY_LENGTH(observed), 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 ac = {0};
    ac.nonce = &n;
    ac.attestation_type = KMIP_ATTEST_TPM_QUOTE;
    ac.attestation_measurement = &am;
    ac.attestation_assertion = &aa;
    
    int result = kmip_encode_attestation_credential(&ctx, &ac);
    result = report_encoding_test_result(
        tracker,
        &ctx,
        expected,
        observed,
        result,
        __func__);
    kmip_destroy(&ctx);
    return(result);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x9d0, %rsp            # imm = 0x9D0
movq %rdi, %rbx
incw (%rdi)
xorps %xmm0, %xmm0
leaq 0xb0(%rsp), %r14
movaps %xmm0, 0x70(%r14)
movaps %xmm0, 0x60(%r14)
movaps %xmm0, 0x50(%r14)
movaps %xmm0, 0x40(%r14)
movaps %xmm0, 0x30(%r14)
movaps %xmm0, 0x20(%r14)
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
leaq 0x138(%rsp), %r15
movl $0x898, %edx            # imm = 0x898
movq %r15, %rdi
xorl %esi, %esi
callq 0x10c0
pushq $0x2
popq %rcx
movl $0x80, %edx
movq %r15, %rdi
movq %r14, %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 0x1724d(%rip), %xmm0    # 0x261c0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
leaq 0x30(%rsp), %rcx
movq %rax, (%rcx)
movq $0x10, 0x8(%rcx)
movaps 0x1be0e(%rip), %xmm0    # 0x2ada0
leaq 0x70(%rsp), %rax
movaps %xmm0, (%rax)
movl $0x99999999, 0x10(%rax) # imm = 0x99999999
leaq 0x20(%rsp), %rdi
movq %rax, (%rdi)
movq $0x14, 0x8(%rdi)
leaq 0x90(%rsp), %rsi
andq $0x0, 0x8(%rsi)
movq %rdx, (%rsi)
movl $0x1, 0x8(%rsi)
movq %rcx, 0x10(%rsi)
movq %rdi, 0x18(%rsi)
movq %r15, %rdi
callq 0x190a8
leaq 0x1bd41(%rip), %rdx     # 0x2ad20
leaq 0x19093(%rip), %r9      # 0x28079
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rcx
movl %eax, %r8d
callq 0x123c
movl %eax, %ebx
movq %r15, %rdi
callq 0x12ade
movl %ebx, %eax
addq $0x9d0, %rsp            # imm = 0x9D0
popq %rbx
popq %r14
popq %r15
retq