// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0xa70, %rsp            # imm = 0xA70
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movw (%rax), %cx
addw $0x1, %cx
movw %cx, (%rax)
leaq -0x90(%rbp), %rdi
leaq 0x2f725(%rip), %rsi     # 0x45d70
movl $0x80, %edx
callq 0x10c0
leaq -0x110(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x1090
leaq -0x9a8(%rbp), %rdi
xorl %esi, %esi
movl $0x898, %edx            # imm = 0x898
callq 0x1090
leaq -0x110(%rbp), %rsi
leaq -0x9a8(%rbp), %rdi
movl $0x80, %edx
movl $0x2, %ecx
callq 0x1c6e0
movl 0x30a7a(%rip), %eax     # 0x47118
movl %eax, -0x9ac(%rbp)
leaq -0x9c0(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq -0x9ac(%rbp), %rax
movq %rax, -0x9c0(%rbp)
movq $0x4, -0x9b8(%rbp)
movl 0x2f71a(%rip), %eax     # 0x45df0
movl %eax, -0x9c6(%rbp)
movw 0x2f711(%rip), %ax      # 0x45df4
movw %ax, -0x9c2(%rbp)
leaq -0x9d8(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq -0x9c6(%rbp), %rax
movq %rax, -0x9d8(%rbp)
movq $0x6, -0x9d0(%rbp)
leaq -0x9e8(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq -0x9c0(%rbp), %rax
movq %rax, -0x9e8(%rbp)
leaq -0x9d8(%rbp), %rax
movq %rax, -0x9e0(%rbp)
movq 0x30b04(%rip), %rax     # 0x47250
movq %rax, -0xa00(%rbp)
movq 0x30afe(%rip), %rax     # 0x47258
movq %rax, -0x9f8(%rbp)
leaq -0xa10(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq -0xa00(%rbp), %rax
movq %rax, -0xa10(%rbp)
movq $0x10, -0xa08(%rbp)
movq 0x2f66c(%rip), %rax     # 0x45e00
movq %rax, -0xa30(%rbp)
movq 0x2f666(%rip), %rax     # 0x45e08
movq %rax, -0xa28(%rbp)
movl 0x2f661(%rip), %eax     # 0x45e10
movl %eax, -0xa20(%rbp)
leaq -0xa40(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq -0xa30(%rbp), %rax
movq %rax, -0xa40(%rbp)
movq $0x14, -0xa38(%rbp)
leaq -0xa60(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x1090
leaq -0x9e8(%rbp), %rax
movq %rax, -0xa60(%rbp)
movl $0x1, -0xa58(%rbp)
leaq -0xa10(%rbp), %rax
movq %rax, -0xa50(%rbp)
leaq -0xa40(%rbp), %rax
movq %rax, -0xa48(%rbp)
leaq -0x9a8(%rbp), %rdi
leaq -0xa60(%rbp), %rsi
callq 0x29350
movl %eax, -0xa64(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x90(%rbp), %rdx
leaq -0x110(%rbp), %rcx
movl -0xa64(%rbp), %r8d
leaq -0x9a8(%rbp), %rsi
leaq 0x2a759(%rip), %r9      # 0x40fc1
callq 0x11f0
movl %eax, -0xa64(%rbp)
leaq -0x9a8(%rbp), %rdi
callq 0x1cab0
movl -0xa64(%rbp), %eax
addq $0xa70, %rsp            # imm = 0xA70
popq %rbp
retq
nop