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

    /* This encoding matches the following set of values:
    *  Response Header
    *      Protocol Version
    *          Protocol Version Major - 2
    *          Protocol Version Minor - 0
    *      Time Stamp - 1335514341
    *      Nonce
    *          Nonce ID - 0x01020304
    *          Nonce Value - 0xFFFFFFFFFFFF
    *      Server Hashed Password - 301EC144E9C6C4F64C29C01C3E11839C97D6E7D2BC0C5DBC68377B679AE51D4D
    *      Attestation Type - TPM Quote
    *      Attestation Type - SAML Assertion
    *      Client Correlation Value - client 1
    *      Server Correlation Value - server 1
    *      Batch Count - 1
    */
    uint8 encoding[224] = {
        0x42, 0x00, 0x7A, 0x01, 0x00, 0x00, 0x00, 0xD8,
        0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
        0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
        0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x42, 0x00, 0x92, 0x09, 0x00, 0x00, 0x00, 0x08,
        0x00, 0x00, 0x00, 0x00, 0x4F, 0x9A, 0x54, 0xE5,
        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, 0x01, 0x55, 0x08, 0x00, 0x00, 0x00, 0x20,
        0x30, 0x1E, 0xC1, 0x44, 0xE9, 0xC6, 0xC4, 0xF6,
        0x4C, 0x29, 0xC0, 0x1C, 0x3E, 0x11, 0x83, 0x9C,
        0x97, 0xD6, 0xE7, 0xD2, 0xBC, 0x0C, 0x5D, 0xBC,
        0x68, 0x37, 0x7B, 0x67, 0x9A, 0xE5, 0x1D, 0x4D,
        0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
        0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
        0x42, 0x01, 0x05, 0x07, 0x00, 0x00, 0x00, 0x08,
        0x63, 0x6C, 0x69, 0x65, 0x6E, 0x74, 0x20, 0x31,
        0x42, 0x01, 0x06, 0x07, 0x00, 0x00, 0x00, 0x08,
        0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x31,
        0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
    };

    KMIP ctx = {0};
    kmip_init(&ctx, encoding, ARRAY_LENGTH(encoding), KMIP_2_0);

    ProtocolVersion pv = {0};
    pv.major = 2;
    pv.minor = 0;

    uint8 id[4] = {0x01, 0x02, 0x03, 0x04};
    ByteString ni = {0};
    ni.value = id;
    ni.size = ARRAY_LENGTH(id);

    uint8 value[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
    ByteString nv = {0};
    nv.value = value;
    nv.size = ARRAY_LENGTH(value);

    Nonce n = {0};
    n.nonce_id = &ni;
    n.nonce_value = &nv;

    uint8 hash[32] = {
        0x30, 0x1E, 0xC1, 0x44, 0xE9, 0xC6, 0xC4, 0xF6,
        0x4C, 0x29, 0xC0, 0x1C, 0x3E, 0x11, 0x83, 0x9C,
        0x97, 0xD6, 0xE7, 0xD2, 0xBC, 0x0C, 0x5D, 0xBC,
        0x68, 0x37, 0x7B, 0x67, 0x9A, 0xE5, 0x1D, 0x4D
    };
    ByteString shp = {0};
    shp.value = hash;
    shp.size = ARRAY_LENGTH(hash);

    enum attestation_type types[2] = {
        KMIP_ATTEST_TPM_QUOTE,
        KMIP_ATTEST_SAML_ASSERTION
    };

    TextString ccv = {0};
    ccv.value = "client 1";
    ccv.size = 8;

    TextString scv = {0};
    scv.value = "server 1";
    scv.size = 8;

    ResponseHeader expected = {0};
    kmip_init_response_header(&expected);

    expected.protocol_version = &pv;
    expected.time_stamp = 1335514341;
    expected.nonce = &n;
    expected.server_hashed_password = &shp;
    expected.attestation_types = types;
    expected.attestation_type_count = ARRAY_LENGTH(types);
    expected.batch_count = 1;

    expected.client_correlation_value = &ccv;
    expected.server_correlation_value = &scv;

    ResponseHeader observed = {0};
    kmip_init_response_header(&observed);

    int result = kmip_decode_response_header(&ctx, &observed);
    int comparison = kmip_compare_response_header(&expected, &observed);
    if(!comparison)
    {
        /* TODO (ph) Reorder these with printing result so that objects are
                     below function name.
        */
        kmip_print_response_header(stderr, 1, &expected);
        kmip_print_response_header(stderr, 1, &observed);
    }
    result = report_decoding_test_result(tracker, &ctx, comparison, result, __func__);

    kmip_free_response_header(&ctx, &observed);
    kmip_destroy(&ctx);
    return(result);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xac8, %rsp            # imm = 0xAC8
movq %rdi, 0x8(%rsp)
incw (%rdi)
leaq 0x21b37(%rip), %rsi     # 0x323b0
leaq 0x150(%rsp), %r15
movl $0xe0, %edx
movq %r15, %rdi
callq 0x1100
leaq 0x230(%rsp), %rbx
movl $0x898, %edx            # imm = 0x898
movq %rbx, %rdi
xorl %esi, %esi
callq 0x10c0
movl $0xe0, %edx
movq %rbx, %rdi
movq %r15, %rsi
movl $0x5, %ecx
callq 0x13177
movl $0x2, %eax
leaq 0x18(%rsp), %rcx
movq %rax, (%rcx)
leaq 0x24(%rsp), %rax
movl $0x4030201, (%rax)      # imm = 0x4030201
leaq 0x80(%rsp), %rcx
movq %rax, (%rcx)
movq $0x4, 0x8(%rcx)
leaq 0x28(%rsp), %rax
movw $0xffff, 0x4(%rax)      # imm = 0xFFFF
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
leaq 0x70(%rsp), %rdx
movq %rax, (%rdx)
movq $0x6, 0x8(%rdx)
leaq 0x60(%rsp), %r13
movq %rcx, (%r13)
movq %rdx, 0x8(%r13)
movaps 0x222c6(%rip), %xmm0    # 0x32be0
leaq 0xe0(%rsp), %rax
movaps %xmm0, 0x10(%rax)
movaps 0x222a3(%rip), %xmm0    # 0x32bd0
movaps %xmm0, (%rax)
leaq 0x50(%rsp), %rbx
movq %rax, (%rbx)
movq $0x20, 0x8(%rbx)
movabsq $0x300000001, %rax      # imm = 0x300000001
leaq 0x10(%rsp), %rcx
movq %rax, (%rcx)
leaq 0x1e925(%rip), %rax     # 0x2f27e
leaq 0x40(%rsp), %r12
movq %rax, (%r12)
movl $0x8, %eax
movq %rax, 0x8(%r12)
leaq 0x1e914(%rip), %rcx     # 0x2f287
leaq 0x30(%rsp), %rbp
movq %rcx, (%rbp)
movq %rax, 0x8(%rbp)
leaq 0x100(%rsp), %r15
xorl %r14d, %r14d
movq %r14, 0x40(%r15)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%r15)
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
movq %r15, %rdi
callq 0x1392b
leaq 0x18(%rsp), %rax
movq %rax, (%r15)
movq $0x4f9a54e5, 0x8(%r15)  # imm = 0x4F9A54E5
movq %r13, 0x18(%r15)
movq %rbx, 0x40(%r15)
leaq 0x10(%rsp), %rax
movq %rax, 0x20(%r15)
movl $0x2, %eax
movq %rax, 0x28(%r15)
movl $0x1, 0x10(%r15)
movq %r12, 0x30(%r15)
movq %rbp, 0x38(%r15)
leaq 0x90(%rsp), %r12
movq %r14, 0x40(%r12)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%r12)
movaps %xmm0, 0x20(%r12)
movaps %xmm0, 0x10(%r12)
movaps %xmm0, (%r12)
movq %r12, %rdi
callq 0x1392b
leaq 0x230(%rsp), %rdi
movq %r12, %rsi
callq 0x271f7
movl %eax, %ebp
movq %r15, %rdi
movq %r12, %rsi
callq 0x17224
testl %eax, %eax
jne 0x10a6a
movq 0x325ba(%rip), %rbx     # 0x42ff8
movq (%rbx), %rdi
leaq 0x100(%rsp), %rdx
movl $0x1, %esi
callq 0x2c696
movq (%rbx), %rdi
leaq 0x90(%rsp), %rdx
movl $0x1, %esi
callq 0x2c696
xorl %eax, %eax
leaq 0x1e8df(%rip), %r8      # 0x2f350
leaq 0x230(%rsp), %r14
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movl %eax, %edx
movl %ebp, %ecx
callq 0x1363
movl %eax, %ebx
leaq 0x90(%rsp), %rsi
movq %r14, %rdi
callq 0x14f03
movq %r14, %rdi
callq 0x13455
movl %ebx, %eax
addq $0xac8, %rsp            # imm = 0xAC8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq