// File: /workspace/github_c_makefile_star2_O0/OpenKMIP[P]libkmip/tests/tests.c
// Function: test_encode_response_header_kmip_2_0
int
test_encode_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 expected[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
    };

    uint8 observed[224] = {0};
    KMIP ctx = {0};
    kmip_init(&ctx, observed, ARRAY_LENGTH(observed), 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 rh = {0};
    kmip_init_response_header(&rh);

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

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

    int result = kmip_encode_response_header(&ctx, &rh);
    result = report_encoding_test_result(tracker, &ctx, expected, observed, result, __func__);

    kmip_destroy(&ctx);
    return(result);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb60, %rsp            # imm = 0xB60
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movw (%rax), %cx
addw $0x1, %cx
movw %cx, (%rax)
leaq -0xf0(%rbp), %rdi
leaq 0x2e4f5(%rip), %rsi     # 0x46880
movl $0xe0, %edx
callq 0x10c0
leaq -0x1d0(%rbp), %rdi
xorl %esi, %esi
movl $0xe0, %edx
callq 0x1090
leaq -0xa68(%rbp), %rdi
xorl %esi, %esi
movl $0x898, %edx            # imm = 0x898
callq 0x1090
leaq -0x1d0(%rbp), %rsi
leaq -0xa68(%rbp), %rdi
movl $0xe0, %edx
movl $0x5, %ecx
callq 0x1c6e0
leaq -0xa70(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x1090
movl $0x2, -0xa70(%rbp)
movl $0x0, -0xa6c(%rbp)
movl 0x2ed13(%rip), %eax     # 0x47118
movl %eax, -0xa74(%rbp)
leaq -0xa88(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq -0xa74(%rbp), %rax
movq %rax, -0xa88(%rbp)
movq $0x4, -0xa80(%rbp)
movl 0x2e523(%rip), %eax     # 0x46960
movl %eax, -0xa8e(%rbp)
movw 0x2e51a(%rip), %ax      # 0x46964
movw %ax, -0xa8a(%rbp)
leaq -0xaa0(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq -0xa8e(%rbp), %rax
movq %rax, -0xaa0(%rbp)
movq $0x6, -0xa98(%rbp)
leaq -0xab0(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq -0xa88(%rbp), %rax
movq %rax, -0xab0(%rbp)
leaq -0xaa0(%rbp), %rax
movq %rax, -0xaa8(%rbp)
movq 0x2ee2d(%rip), %rax     # 0x472e0
movq %rax, -0xad0(%rbp)
movq 0x2ee27(%rip), %rax     # 0x472e8
movq %rax, -0xac8(%rbp)
movq 0x2ee21(%rip), %rax     # 0x472f0
movq %rax, -0xac0(%rbp)
movq 0x2ee1b(%rip), %rax     # 0x472f8
movq %rax, -0xab8(%rbp)
leaq -0xae0(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq -0xad0(%rbp), %rax
movq %rax, -0xae0(%rbp)
movq $0x20, -0xad8(%rbp)
movq 0x2ee49(%rip), %rax     # 0x47360
movq %rax, -0xae8(%rbp)
leaq -0xaf8(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq 0x28c8e(%rip), %rax     # 0x411c6
movq %rax, -0xaf8(%rbp)
movq $0x8, -0xaf0(%rbp)
leaq -0xb08(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq 0x28c6b(%rip), %rax     # 0x411cf
movq %rax, -0xb08(%rbp)
movq $0x8, -0xb00(%rbp)
leaq -0xb50(%rbp), %rdi
xorl %esi, %esi
movl $0x48, %edx
callq 0x1090
leaq -0xb50(%rbp), %rdi
callq 0x1d570
leaq -0xa70(%rbp), %rax
movq %rax, -0xb50(%rbp)
movq $0x4f9a54e5, -0xb48(%rbp) # imm = 0x4F9A54E5
leaq -0xab0(%rbp), %rax
movq %rax, -0xb38(%rbp)
leaq -0xae0(%rbp), %rax
movq %rax, -0xb10(%rbp)
leaq -0xae8(%rbp), %rax
movq %rax, -0xb30(%rbp)
movq $0x2, -0xb28(%rbp)
movl $0x1, -0xb40(%rbp)
leaq -0xaf8(%rbp), %rax
movq %rax, -0xb20(%rbp)
leaq -0xb08(%rbp), %rax
movq %rax, -0xb18(%rbp)
leaq -0xa68(%rbp), %rdi
leaq -0xb50(%rbp), %rsi
callq 0x29d40
movl %eax, -0xb54(%rbp)
movq -0x8(%rbp), %rdi
leaq -0xf0(%rbp), %rdx
leaq -0x1d0(%rbp), %rcx
movl -0xb54(%rbp), %r8d
leaq -0xa68(%rbp), %rsi
leaq 0x28c2a(%rip), %r9      # 0x41273
callq 0x11f0
movl %eax, -0xb54(%rbp)
leaq -0xa68(%rbp), %rdi
callq 0x1cab0
movl -0xb54(%rbp), %eax
addq $0xb60, %rsp            # imm = 0xB60
popq %rbp
retq
nop